Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support `parent` of top-level abstract clafers #84

Open
mantkiew opened this issue Apr 4, 2016 · 1 comment
Open

Support `parent` of top-level abstract clafers #84

mantkiew opened this issue Apr 4, 2016 · 1 comment
Assignees
Milestone

Comments

@mantkiew
Copy link
Member

@mantkiew mantkiew commented Apr 4, 2016

The following model

abstract FeatureModel
abstract Feature
    [ parent in Feature, FeatureModel]

produces an error

Compile error at line 3 column 7...
Function 'in' cannot be performed on
TClafer {_hi = ["root"]}
in
TClafer {_hi = ["c0_Feature","c0_FeatureModel"]}

the type checker incorrectly assumes that the parent of an abstract clafer is the root.

@mantkiew mantkiew self-assigned this Apr 4, 2016
@mantkiew mantkiew added this to the 0.4.4 milestone Apr 4, 2016
@mantkiew
Copy link
Member Author

@mantkiew mantkiew commented Apr 8, 2016

After fixing the compiler (commit), the following model

abstract FeatureModel
abstract Feature
    [ parent in Feature, FeatureModel]


FM : FeatureModel
    F1 : Feature
       F2 : Feature

produces a correct Choco output with a statement

c0_Feature.addConstraint($in(joinParent($this()), union(global(c0_Feature), global(c0_FeatureModel))));

for which Choco errors with

Exception in thread "main" org.clafer.ast.analysis.TypeException: Cannot join abstract c0_Feature . parent

Also, the model produces an incorrect Alloy output

abstract sig c0_Feature
{}
{ (this.~@r_c0_Feature) in (c0_Feature + c0_FeatureModel) }

because r_c0_Feature is not defined. Actually, it should be a derived union of the parents of the concrete clafers:

r_c0_Feature = r_c0_F1 + r_c0_F2

so, the correct Alloy code should be

abstract sig c0_Feature
{}
{ (this.~@(r_c0_F1 + r_c0_F2) in (c0_Feature + c0_FeatureModel) }
@mantkiew mantkiew mentioned this issue Jun 23, 2016
@mantkiew mantkiew modified the milestones: 0.4.5, 0.4.4 Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.