Conflicts between "defines unique" and "imports" aren't noted
Name conflicts between “defines unique” and “imports” aren’t detected as errors. For example, starting with the example project and adding:
sample.sdf3:
Definition.EntityExtension = < entity <ID> extends <ID> { <{Property "\n"}*> } >
sample.nab:
EntityExtension(x, y, _) : defines Entity x of type Type(x) refers to Entity y scopes Property imports Property from Entity y
No redefinition error occurs when an imported property is redefined:
Submitted by Peter S. Housel on 2 January 2015 at 23:45entity BlogPosting { poster : User body : String } entity BlogPostingX extends BlogPosting { body : String }
Issue Log
The rule is that local definitions shadow imported definitions. Thus the
body
ofBlogPostingX
overrides that ofBlogPosting
. This exactly what one would expect from inheritance in an OO language.
(Removing the superfluous “refers to Entity y” doesn’t change anything.)
If I want to prevent this sort of shadowing of imports is there any way of doing so within the NaBL language, or would I have to implement additional semantic checks in Stratego?
This has to be implemented as a constraint in Stratego. See https://github.com/TUDelft-IN4303/assignments/blob/master/milestone2-analysis/day6.md#custom-constraints and https://github.com/TUDelft-IN4303/assignments/blob/master/milestone2-analysis/day9.md#hiding-variables-and-fields for information on how to do this.
Since you are working with imports, you will want to use the
nabl-lookup-local-import(|ctx)
andnabl-lookup-lexical-import(|ctx)
variants that take imports into account.
Log in to post comments