From e6689015df7d031dec66d3cc97a9a00f3257ccf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20Hac=C4=B1bekiro=C4=9Flu?= Date: Tue, 19 May 2020 17:24:03 +0300 Subject: [PATCH] Fix nested file imports (#282) * fix nested file import * better bytes prefix check * remove comment --- cmd/tengo/main.go | 3 +-- compiler.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/tengo/main.go b/cmd/tengo/main.go index f67e2a8..afddd68 100644 --- a/cmd/tengo/main.go +++ b/cmd/tengo/main.go @@ -67,8 +67,7 @@ func main() { os.Exit(1) } } else if filepath.Ext(inputFile) == sourceFileExt { - if len(inputData) > 1 && - bytes.Compare(inputData[:2], []byte("#!")) == 0 { + if len(inputData) > 1 && string(inputData[:2]) == "#!" { copy(inputData, "//") } err := CompileAndRun(modules, inputData, inputFile) diff --git a/compiler.go b/compiler.go index 6ecc986..1e2a494 100644 --- a/compiler.go +++ b/compiler.go @@ -1086,6 +1086,7 @@ func (c *Compiler) fork( child := NewCompiler(file, symbolTable, nil, c.modules, c.trace) child.modulePath = modulePath // module file path child.parent = c // parent to set to current compiler + child.allowFileImport = c.allowFileImport return child }