result-expression-is-ambiguous
Available in: KerML, SysML
This checks that if a function or expression has an owned or inherited return parameter with a bound value, it has no owned or inherited result expression.
This avoids the ambiguity when selecting the result to use during evaluation, and
conflicting expressions. default return parameters are accepted because they allow the
value to be overridden like with feature-value-overriding constraint.
Specification
Per KerML 7.4.8.2:
The result of a function can also be explicitly bound, either using a binding connector (see 7.4.6.3 ) or a feature value on the result parameter declaration (see 7.4.11 ). In this case, the body of the function should not include a result expression.
Example
function F {
in x;
in y;
return result = x + y;
x - y // error: A function body should not include a result expression
}
Remove either return parameter, or result expression:
function F0 {
in x;
in y;
return result = x + y; // ok
}
function F1 {
in x;
in y;
x - y // ok
}
Or change return parameter to default:
function F {
in x;
in y;
return result default x + y;
x - y // ok
}