Skip to content

ST6RI-923 Problem with name resolution when using Semantic metadata#744

Merged
seidewitz merged 2 commits intomasterfrom
ST6RI-923
Mar 22, 2026
Merged

ST6RI-923 Problem with name resolution when using Semantic metadata#744
seidewitz merged 2 commits intomasterfrom
ST6RI-923

Conversation

@seidewitz
Copy link
Copy Markdown
Member

@seidewitz seidewitz commented Mar 21, 2026

This PR fixes a bug that could cause an incorrect name resolution when using semantic metadata.

Background
The following SysML model should parse, with p1::a redefining P::a:

part def P {
    attribute a;
}
part p : P;

metadata def M :> Metaobjects::SemanticMetadata {
    :>> baseType = p meta SysML::Usage;
}

part def Q {
    attribute a = 1;
    part p1 {
        metadata m : M;
        attribute :>> a = 2;
    }
}

Previously, this worked in the Eclipse Xtext editor, but in Jupyter the model gave the errors:

ERROR:Cannot override a binding feature value (1.sysml line : 16 column : 29)
WARNING:Duplicate of inherited member name 'a' from P (1.sysml line : 16 column : 13)

In Jupyter, name resolution happens during top-down transformation of the model. During the transformation of p1, the reference to the semantic metadata M must be resolved in order to get the implied base type for p1. This name resolution begins in the scope of p1, resultin in the redefined feature namea being resolved early, in order to check the (effective) name of the redefining feature. But, at this point, inheritance from the implied base type is blocked, in order to avoid circular resolution of M. So the reference to a in p1 resolves to Q::a.

In Eclipse, the Xtext reconciler proxy resolution works bottom up, resolving the proxy for M in the declaration of m before processing m as semantic metadata during the transformation of p1. When a is resolved, this triggers the adding of the implied subsetting of p1 by P, so the reference to a resolves to P::a (as it should).

Changes

  1. Created an Xpect test ParsingTests_SemanticMetadata.kerml.xt. Since the underlying problem is in the KerML core, it is a KerML Xpect test similar to the above SysML model. Name resolution in Xpect is similar to Jupyter, so the following model had errors previously, but does not have errors after the change below is made.
    classifier P {
        feature a;
    }
    feature p : P;
    
    metaclass M :> Metaobjects::SemanticMetadata {
        :>> baseType = p meta KerML::Feature;
    }
    
    classifier Q {
        feature a = 1;
        feature p1 {
            metadata m : M;
            feature :>> a = 2;
        }
    }
    
  2. Add the call metadataFeature.getMetaclass() in the method TypeAdapter::getBaseTypes in the loop over the owned metadata features of a typ ethat compute the implied base types from those metadata features that are semantic metadata. The call is added such that any proxy resolution (requiring name resolution) for the metaclass will happen before the computation of the base type.

- Fixes the handling of resolution of names of references to members
inherited from the implied base type.
- Avoids possibility of improper resolution of other names when using
semantic metadata.
@seidewitz seidewitz requested a review from himi March 21, 2026 22:27
@seidewitz seidewitz self-assigned this Mar 21, 2026
@seidewitz seidewitz added the bug Something isn't working label Mar 21, 2026
@seidewitz seidewitz added this to the 2026-02 milestone Mar 21, 2026
@himi
Copy link
Copy Markdown
Member

himi commented Mar 22, 2026

I'm trying to test your example on Jupyter. Is there any way to evaluate KerML on Jupyter SysML kernel?

@seidewitz
Copy link
Copy Markdown
Member Author

I'm trying to test your example on Jupyter. Is there any way to evaluate KerML on Jupyter SysML kernel?

No, the Jupyter deployment cannot parse KerML.

I wrote the PR description poorly. The bug was originally identified in a SysML model. However, since the underlying cause was in the KerML Core implementation, the Xpect test for the resolution is a KerML test. The KerML model shown in the PR description is from the Xpect test.

I have updated the PR description to make this clearer.

@himi
Copy link
Copy Markdown
Member

himi commented Mar 22, 2026

Ed, thank you. I found one typo in your example in Line 17 (Metadataobjcts should be Metaobjects) and

part def P {
    attribute a;
}
part p : P;

metadata def M :> Metaobjects::SemanticMetadata {
    :>> baseType = p meta SysML::Usage;
}

part def Q {
    attribute a = 1;
    part p1 {
        metadata m : M;
        attribute :>> a = 2;
    }
}

was evaluated successfully with

PartDefinition P (735d88fe-7971-4a91-8ea4-91393f8de22e)
PartUsage p (de414c8d-bfa7-4275-972c-232d83846b3c)
MetadataDefinition M (c67eec8d-8221-4bb8-9bbf-89548910c411)
PartDefinition Q (017f6523-1350-478c-a7ff-9524e6a742b2)

@seidewitz
Copy link
Copy Markdown
Member Author

I found one typo in your example in Line 17 (Metadataobjcts should be Metaobjects)

Oops. That was a manual change after I copied the validated text from the editor. I've fixed it now!

@seidewitz seidewitz merged commit 87eb972 into master Mar 22, 2026
2 checks passed
@seidewitz seidewitz modified the milestones: 2026-02, 2026-03 Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants