Hiding errors do not work for definitions in external scopes (1)
Currently, duplicate errors are detected by creating a resolution task based on the URI of a definition site. When the task has multiple results, an error is reported. This does not work for definitions in external scopes, because they will always get a fresh scope. Instead, the resolution task needs to be created for each external scope of a definition, using the URI in the
Submitted by Guido Wachsmuth on 17 July 2013 at 23:34Alias
.
Issue Log
Is there any example of a duplicate definition introduced by definitions in external scopes in Green-Marl? The following example has a possible hiding error, not duplicate definiton right?
Foreach(n : G.Nodes) { Foreach(n : G.Nodes) { } }
@Gabriël: i don’t think so, because of the quirkiness of the language. But i guess we could craft an example in a another language.
You can get a duplicate error by rules like this:
Foo(x, Bar(_, t)): defines Var x in t Bar(x, t): defines Var x in t
I’ve made a branch on GM for testing this - fix/nabl-60. I’ve separated some tests for this issue, located at Green-Marl/test/spts/nabl-60.spt. The check for hiding is defined in Green-Marl/trans/types/checks.str.
This isssue is related to https://yellowgrass.org/issue/NaBL/57 through the current implementation.
This was fixed in the latest version of runtime-libraries and Green-Marl. The pattern looks like:
type-of(|ctx): name -> <fail> with uri := <nabl-uri> name; if inverse-alias := <nabl-get-inverse-alias> uri then uri' := <nabl-uri-parent> inverse-alias else uri' := <nabl-uri-parent> uri end; task* := <nabl-use-subtasks(id, fail|ctx, <nabl-uri-namespace> uri, <nabl-uri-name> uri, [], All())> uri'; task := <new-task(|ctx)> Concat(task*); <task-create-error-on-multiple(|ctx, task, "Declaration hides previous definition")> name
Actually this pattern is better:
nabl-hiding-task(|partition): name -> name where uri := <nabl-uri> name; ns := <nabl-uri-namespace> uri; if inverse-alias := <nabl-get-inverse-alias> uri then uri' := <nabl-uri-parent; nabl-uri-parent> inverse-alias else uri' := <nabl-uri-parent; nabl-uri-parent> uri end; task* := <nabl-use-subtasks(id, fail|partition, ns, <nabl-fix-name> name, [], All())> uri'; task := <new-task(|partition)> Choice(task*); <task-create-error-on-success(|partition, task, "Declaration hides previous definition")> name
Log in to post comments