Fix nested file imports (#282)

* fix nested file import

* better bytes prefix check

* remove comment
This commit is contained in:
Ozan Hacıbekiroğlu 2020-05-19 17:24:03 +03:00 committed by GitHub
parent 50d0ba75d5
commit e6689015df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -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)

View file

@ -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
}