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 Alias.

Submitted by Guido Wachsmuth on 17 July 2013 at 23:34

On 17 July 2013 at 23:34 Guido Wachsmuth tagged @gohla

On 17 July 2013 at 23:35 Guido Wachsmuth tagged !vvergu

On 18 July 2013 at 02:00 Gabriël Konat commented:

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) { } }


On 18 July 2013 at 17:47 Vlad Vergu commented:

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


On 18 July 2013 at 17:50 Guido Wachsmuth commented:

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

On 18 July 2013 at 19:45 Vlad Vergu commented:

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.


On 18 July 2013 at 22:23 Vlad Vergu commented:

This isssue is related to https://yellowgrass.org/issue/NaBL/57 through the current implementation.


On 19 July 2013 at 00:17 Gabriël Konat commented:

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

On 20 July 2013 at 01:24 Gabriël Konat commented:

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

On 20 July 2013 at 01:24 Gabriël Konat closed this issue.

Log in to post comments