Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving astId of list term gets astId of first element instead #111

Open
RvanBaarle opened this issue Feb 10, 2023 · 2 comments
Open

Comments

@RvanBaarle
Copy link

Bug description

Versions
Spoofax version: Spoofax 3 (local branch at https://github.com/RvanBaarle/spoofax-pie/develop), using nabl repository at commit 36b9fad6
Statix setup: single-file

Steps to reproduce the behavior
See this stxtest file:

resolve

  bugged([Test(), Other()])

signature
  sorts Test
  constructors
    Test : Test
    Other : Test

rules

  bugged : list(Test)
  bugged(a@[h|t]) :- {id1 id2 id3}
    astId(a, id1),
    astId(h, id2),
    astId(t, id3),
    try { false } | note$[list id: [id1]   head id: [id2]   tail id: [id3]].

  bugged2 : list(Test)
  bugged2(a) :- {id}
    astId(a, id),
    try { false } | note$[list id: [id]].

Observed behavior
The ids for term a and h are both 5. When compared to the output of Show Analyzed AST this appears to be the id corresponding to term h.
The bugged2 rule shows that this issue also occurs when the [h|t] syntax isn't used.

Expected behavior
The id for term a should be the id for the list term, corresponding to what's shown by Show Analyzed AST. Instead of the id of the head term of the list term.

Additional context
This bug makes it impossible to assign properties (@x.prop := y) to list terms, as it'll get assigned to the head term instead.

@AZWN
Copy link
Contributor

AZWN commented Feb 24, 2023

Indeed, this is a strange bug. How urgent is it for your progress?

@RvanBaarle
Copy link
Author

It's not urgent, I worked around it by defining an extra AST term encapsulating the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants