metaborg / nabl

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

Fail to show message on try if inner constraint fails #71

Closed MeAmAnUsername closed 3 years ago

MeAmAnUsername commented 3 years ago

Bug description Calling a failing predicate in a try block will not show a message on the try if the predicate has a warning or note after the constraint that fails.

Versions Eclipse: org.eclipse.platform.ide 4.16.0.I20200604-0540 Spoofax: org.metaborg.spoofax.eclipse 2.6.0.20210816-152350-master System: Mac OS X x86_64 10.14.6 Statix setup: (none, it's not a language project, just a stxtest)

Steps to reproduce the behavior

resolve
  try { pred(1) } | note "pred 1 failed",
  try { pred(2) } | note "pred 2 failed",
  try { pred(3) } | note "pred 3 failed",
  try { pred(4) } | note "pred 4 failed",
  try { pred(5) } | note "pred 5 failed",
  try { pred(6) } | note "pred 6 failed",
  try { pred(7) } | note "pred 7 failed"

rules

  pred : int

// Bug only happens if it is a note or warning that is checked _after_ the failing constraint false.
// correctly show messages
  pred(1) :- false.
  pred(2) :- false.
  pred(3) :-
    try {false} | note $[in pred 3],
    false.
  pred(4) :-
    try {false} | warning $[in pred 4],
    false.
  pred(5) :-
    false,
    try {false} | error $[in pred 5].

// do not show messages
  pred(6) :-
    false,
    try {false} | warning $[in pred 6].
  pred(7) :-
    false,
    try {false} | note $[in pred 7].

Observed behavior it prints messages for pred X failed for 1-5, but not for 6 and 7.

Expected behavior It prints messages for all seven predicates.

AZWN commented 3 years ago

Nice catch. Entailments contexts used an incorrect short-circuiting condition. It should be fixed in c815cde09b238e30dd4bc1ac1ad27d16d25ce144.