metaborg / nabl

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

astId is ignored when used as location for message #74

Open MeAmAnUsername opened 3 years ago

MeAmAnUsername commented 3 years ago

Bug description A message with an astId as location will not be shown on that astId but will be treated as if it didn't have an explicit location (i.e. goes up the stacktrace and uses the first ast node it finds)

Versions Eclipse: org.eclipse.platform.ide 4.16.0.I20200604-0540 Spoofax: org.metaborg.spoofax.eclipse 2.6.0.20210903-091634-master System: Mac OS X x86_64 10.14.6 Statix setup: single file

Steps to reproduce the behavior stx test files do not show the node the error appears on, so you get a full Spoofax project instead. The full project is attached as statixbugastidmessagelocation.zip, relevant parts are shown here: Syntax:

context-free syntax

  Start.Elems = [[Elem], [Elem]]
  Elem.Elem = [[INT]]

Statix:

module statics

// see README.md for details on how to switch to multi-file analysis

rules // single-file entry point

  programOk : Start

  programOk(Elems(e1, e2)) :-
    check(e1, astId(e1)),
    check(e1, astId(e2)).

  check : Elem * astId
  check(elem, node) :- false | error $[elem [elem], astId([node])] @node.

signature

  sorts Start constructors
    Elems : Elem * Elem -> Start

  sorts Elem constructors
    Elem : Elem

Example file (example/test.sta)

1, 2

Observed behavior There are two errors on 1. This always happens.

Expected behavior One error on 1, one error on 2.

Additional context Slack threads: