eclipse-xtext / eclipse-xtext/xtext

Attributes not correctly uplifted in combination with multiple supertypes

Open
#2,596 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

confirmed
Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Description

For the grammar

Model:
	Rule1 | Rule2 | Rule3;

Rule1:
	'Rule1' name=ID frag;

Rule2:
	'Rule2' name=ID frag;

Rule3:
	'Rule3' name=ID;

fragment frag:
	'frag' someattribute=STRING;

the generated class hierarchy is not correctly inferred as the common name attribute is not lifted into the Model class.

Interestingly, this behaviour is determined by the order of appearance in the Xtext file:

  • If the non-fragment rule is the first or second, inference works correctly
  • Switching the alternative options in Model (e.g. to "Rule1 | Rule3 | Rule2") however has no effect
  • "Physically" moving Rule3 definition between Rule1 and Rule2 (not changing any numbers) does make inference work correctly again

Update @cdietrich

same problem with other supertypes as well

Model:
	Rule1 | Rule3 | Rule2;

Rule1:
	{Rule1}'Rule1' name=ID;

Rule2:
	{Rule2}'Rule2' name=ID;

Rule3:
	'Rule3' name=ID;

Frag: Rule1 | Rule2;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the grammar shown in the report, including the alternate example with additional supertypes. Trace the inferred generated class hierarchy and compare results when Rule3 is moved or the alternatives are reordered. Done means the shared name attribute is consistently lifted into the common Model class regardless of rule order.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.