SysML 2.1b1 RTF Avatar
  1. OMG Issue

SYSML21 — For loop variable typing is not as expected

  • Key: SYSML21-625
  • Status: open  
  • Source: Model Driven Solutions ( Mr. Ed Seidewitz)
  • Summary:

    In the following example,

    attribute def Data {
        attribute mass;
    }
    action def ForLooping {
        in attribute data [1..*] : Data;
        for element in data {
            attribute elementMass = element.mass; 
        }
    }
    

    the name mass cannot be resolved in the feature chain element.mass. This is because the loop variable is not being implicitly typed by Data, as one might expect.

    The for loop action usage above is being parsed equivalently to:

    action subsets loopActions {
        ref element redefines ForLoopAction::var subsets seq;
        in seq subsets ForLoopAction::seq = data;
        in body = { ... };
    }
    

    The loop variable element has an implied subsetting of the local redefinition of the parameter seq. However, because seq is a parameter (directed), it does not have any specialization based on its feature value expression data (see the constraint checkFeatureValuationSpecialization). So Data ends up with the typing of ForLoopAction::seq, which is Anything.

  • Reported: SysML 2.0 — Tue, 12 May 2026 18:13 GMT
  • Updated: Tue, 12 May 2026 18:13 GMT