Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341155

Summary: [ConcreteSyntaxValidator] Actions - [...] holds y non-transient value(s), but exactly 0 are required
Product: [Modeling] TMF Reporter: Dietmar Stoll <btickets>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: moritz.eysholdt
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Dietmar Stoll CLA 2011-03-28 15:49:18 EDT
Build Identifier: I20100608-0911

The following is a part of an interface definition language (IDL) file for which an Xtext grammar was written. It shows a method with a parameter declaration.

void getFoo (  
  in Bar bar,          
  in MyType type,
  out MyOtherType outparam,      
  out MyType otherOutparam
); 

The rule "ParameterDcls" parses everything after the method name "getFoo", including the brackets. The contents of the brackets may be empty, i.e. the method may have no parameters.

With the following rule, the file opens without errors in the Xtext runtime editor, but programatically reading and then serialising the file yields an error.

ParameterDcls:
 "(" paramDcl+=ParamDcl ("," paramDcl+=ParamDcl)* ")"
 | {ParameterDcls} "(" ")"
; 

org.eclipse.xtext.validation.IConcreteSyntaxValidator$InvalidConcreteSyntaxException: These errors need to be fixed before the model can be serialized.

IdlModel.definitions[7]->InterfaceDcl.body->InterfaceBody.exports[3]->OpDcl'getFoo'.parameters->ParameterDcls: Feature ParameterDcls.paramDcl holds 4 non-transient value(s), but exactly 0 are required.

        at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:51)
        at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:61)
        at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:287)
        at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1406)

With the following variant of the rule, the file can be serialized fine. The two rules seem to be semantically equivalent.

ParameterDcls:
 {ParameterDcls} "(" (paramDcl+=ParamDcl ("," paramDcl+=ParamDcl)*)? ")";.

Reproducible: Always
Comment 1 Moritz Eysholdt CLA 2011-03-29 08:42:36 EDT
This is actually a false-positive from the ConcreteSyntaxValidator.
Comment 2 Dietmar Stoll CLA 2011-03-31 11:18:56 EDT
Here is another example.

Extract from IDL language:
union MyUnion_Type switch (char) {
    case MY_CONSTANT:
        MyType myTypeName;
    case MY_OTHER_CONSTANT:
       MyOtherType myOtherTypeName;
  };

Parser rule for the "case"-Part which yields a similar error message as in the original bug report:
CaseLabel:
  "case" constExp=ConstExp ":"
  | {CaseLabel} "default" ":"
;

[...] .switchBody->SwitchBody.case[0]->Case.caseLabel[0]->CaseLabel: Feature CaseLabel.constExp must not be set.

Parser rule which works fine:
CaseLabel:
  {CaseLabel} ("case" constExp=ConstExp | "default") ":"
;
Comment 3 Moritz Eysholdt CLA 2016-07-21 05:14:17 EDT
won't fix due to https://github.com/eclipse/xtext-core/issues/48