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

Comments

Projects
None yet
1 participant
@mantkiew
Member

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

This comment has been minimized.

Show comment
Hide comment
@mantkiew

mantkiew Apr 8, 2016

Member

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

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 referenced this issue Jun 23, 2016

Merged

Release 0.4.4 #88

@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