scriggo
scriggo copied to clipboard
compiler/checker: investigate if importing the same name twice is handled correctly
In the function checkImport
we import the names without checking if they have already been imported.
Not sure if this may lead to incosistencies, we should investigate on it.
NOTE: before proceeding, wait for the merge of the PR #856.
Consider this scenario:
// main.go
package main
import (
. "test/bar"
. "test/foo"
)
func main() {
Foo()
Bar()
}
// bar/bar.go
package bar
func F() {}
func Bar() {}
// foo/foo.go
package foo
func F() {}
func Foo() {}
gc returns the error:
./main.go:5:2: F redeclared during import "test/foo"
main.go:4:2: previous declaration during import "test/bar"
We should consider and test the various combinations of native and non-native imported names. For example:
- first declaration imported is native, a second one (with the same name) is native too
- first declaration imported is native, a second one (with the same name) is not native
etc...
This code does not return error:
"https://github.com/open2b/scriggo/issues/859": {
sources: fstest.Files{
"index.html": `
{% import "foo.html" %}
{% import "bar.html" %}
{{ Foo() }}
{{ Bar() }}
`,
"foo.html": `
{% macro F() %}{% end macro %}
{% macro Foo() %}{% end macro %}
`,
"bar.html": `
{% macro F() %}{% end macro %}
{% macro Bar() %}{% end macro %}
`,
},
},
Neither this:
"https://github.com/open2b/scriggo/issues/859": {
sources: fstest.Files{
"index.html": `
{% import "foo.html" %}
{% import "bar.html" %}`,
"foo.html": `{% macro F() %}{% end macro %}`,
"bar.html": `{% macro F() %}{% end macro %}`,
},
},
They both should return a redeclaration error.