Incorrect properties lifting to the parent node
See original GitHub issueRules AssignmentExpression
, OrExpression
and AndExpression
have a common property operator
and inherit BinaryExpression
, so the BinaryExpression
in the generated AST interface has to contain a property operator: 'Or' | 'And' | ':'
. However, type of the operator
is 'Or' | 'And'
, because it omits an operator of the AssignmentExpression
rule.
entry Model:
elements+=OrAndAssignmentExpression*;
OrAndAssignmentExpression infers Expression:
OrExpression ({infer AssignmentExpression.left=current} operator=':' right=OrExpression)*;
// Dummy rule to make AssignmentExpression inherit from BinaryExpression
AssignmentExpression infers BinaryExpression:
{infer AssignmentExpression} left=ID operator=':' right=OrExpression;
OrExpression infers Expression:
AndExpression ({infer BinaryExpression.left=current} operator='Or' right=AndExpression)*;
AndExpression infers Expression:
ValueExpression ({infer BinaryExpression.left=current} operator='And' right=ValueExpression)*;
ValueExpression infers Expression:
{infer BoolValue} value=BOOL | {infer IDValue} value=ID;
terminal ID: /\$?[_a-zA-Z][\w_]*/;
terminal BOOL returns boolean: /(true)|(false)/;
Langium version: 0.5.0 Package name: langium-cli
Steps To Reproduce
- Generate an AST with the grammar above
- Check out the
BinaryExpression
rule in the AST
The current behavior
Type of operator
from BinaryExpression
doesn’t contain ':'
.
export interface BinaryExpression extends Expression {
operator: 'Or' | 'And'
...
}
The expected behavior
Type of operator
from BinaryExpression
contain ':'
.
export interface BinaryExpression extends Expression {
operator: 'Or' | 'And' | ':'
...
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
The Checked property of a parent node is incorrectly updated ...
Hi issue still present. It is fixed partial case on moment when node being hidden. When you add node after hiding some node...
Read more >Slot content has incorrect parentNode value #658 - GitHub
We found this issue with slots by comparing with native Shadow DOM. shadow -> slot -> assigned nodes -> div -> parent =...
Read more >Editing and organising nodes - NVivo 12 for Windows
In List View, select the Node to be renamed. Right click and select Node Properties. Enter desired changes to the name and click...
Read more >SKSpriteNode gets hidden below parent node - Stack Overflow
Using Swift and SpriteKit, I have a problem with SKSpriteNode not showing when being added as a child to another SKSpriteNode. In contrast,...
Read more >parentNode Property1 | Microsoft Learn
The property is read-only. All nodes except Document, DocumentFragment, and Attribute nodes can have a parent. However, if a node has just ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll jump on this one :octocat:
There’s also a problem w/ formal reasoning about what makes a rule valid, until 510 is added. Currently we can’t assume that a rule returning some type (inferred or declared) will be valid if it satisfies the properties stated by the type, because we can’t validate the inheritance that is used to build that type. Normally we could duplicate the property in the child type to fix this, but that’s disallowed, and puts us in a bit of a quandary.