scriggo icon indicating copy to clipboard operation
scriggo copied to clipboard

fix: handle template imports without file extensions

Open phihos opened this issue 1 month ago • 0 comments

The emitter incorrectly used filepath.Ext() to distinguish template imports from native package imports. This caused imports without file extensions to be silently skipped, resulting in:

panic: scriggo: internal error: none of the previous conditions matched identifier <MacroName>

The correct check is node.Tree != nil, which indicates a template import (parsed AST exists) vs node.Tree == nil for native package imports. This matches the logic used in the type checker.

Changes:

  • emitter_statements.go: Replace filepath.Ext check with node.Tree check
  • fstest/files.go: Add FormatFiles type for testing extension-less imports
  • multi_file_template_test.go: Add tests for extension-less macro/variable imports

phihos avatar Dec 12 '25 13:12 phihos