metaborg / nabl

Spoofax' Name Binding Language
Apache License 2.0
7 stars 12 forks source link

Custom error message not triggering. #97

Closed ReiniervdG closed 2 years ago

ReiniervdG commented 2 years ago

Bug description When asserting that a query results in exactly one result, my custom error message is not triggered, but instead an error occurs indicating a mismatch between a wildcard and an empty list.

Versions Spoofax version: Spoofax Eclipse runtime 2.6.0.20220228-175858-master Statix setup: single-file

Steps to reproduce the behavior Reproduction in .stxtest file as follows:

resolve classDeclarationOk("MyClass")

signature 

  relations
    ConstructorDeclaration :

rules
  classDeclarationOk : string

  classDeclarationOk(id) :- {static_scope}
    new static_scope,
    assertUniqueConstructor(static_scope).

rules

  assertUniqueConstructor : scope

  assertUniqueConstructor(s) :-
    query ConstructorDeclaration
      filter e
      in s |-> [_] | error "Custom error message".

Observed behavior Error message in stxtest evaluation:

substitution

analysis
  scope graph

errors
  : [?wld32-2] == []<br>

warnings
notes

Expected behavior Expected to output the "Custom error message".

--

PS: issue default text suggests to read 'https://www.spoofax.dev/spoofax-docs/howtos/statix/debugging/', but points to a 404, probably should be 'https://www.spoofax.dev/howtos/statix/debugging/'. Same for references/statix.

AZWN commented 2 years ago

Thanks for reporting. This is indeed a bug introduced in a recent improvement in query execution. It should be fixed in 17e02f04e905cedd7293c8f3ba20772348d82bb6.