metaborg / nabl

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

Cascading errors in the WebDSL specification #107

Open maxdekrieger opened 2 years ago

maxdekrieger commented 2 years ago

Short description A rare case of a cascading error during typechecking of a WebDSL program.

Problem description. In the following WebDSL snippet, a predicate should contain a boolean result, but a more specific error occurs in the addition (adding int + bool). Statix shows both while in the ideal case it would only show the error of adding an int to a bool.

  predicate foo(i:Int){
    i+false
  }

The error should be caught with the following constraint:

equalType(typeOfExp(s_predicate, exp), bool) | error $[Predicate should contain a Bool expression] @exp.

normalized:
      (typeOfExp(s_predicate, exp, typeOfExp332) | error $[Predicate should contain a Bool expression] @exp,
       equalType(typeOfExp332, bool) | error $[Predicate should contain a Bool expression] @exp),

Describe the solution you'd like Ideally the error given by the typeOfExp predicate should be the only error shown, namely that adding an int to a bool is untyped.

Describe alternatives you've considered None

Additional context Failing test on the WebDSL buildfarm: https://buildfarm.metaborg.org/job/webdsl/job/webdsl-statix/job/master/117/artifact/analysis-results/analysis__1-original-compiler-tests__analysis-fails__ac__predicateboolexp-2__FAILED.

Statix snippet: https://github.com/webdsl/webdsl-statix/blob/584fdf1b29ce2c2a6b094bae0e24b64a1f1efb7d/webdslstatix/trans/static-semantics/webdsl-ac.stx#L188-L199