metaborg / nabl

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

Stxtest results do not show variables declared after constraints #67

Open MeAmAnUsername opened 3 years ago

MeAmAnUsername commented 3 years ago

Bug description Stxtest results do not show variables declared after constraints.

Versions Eclipse: org.eclipse.platform.ide 4.16.0.I20200604-0540 Spoofax: org.metaborg.spoofax.eclipse 2.6.0.20210526-183432-master System: Mac OS X x86_64 10.14.6 multi-file analysis

Steps to reproduce the behavior Spoofax > Evaluate > Evaluate test

resolve {s1}
  {s2}
  new s1,
  {s3}
  new s3

Observed behavior Substitution only shows the variable declared before any constraints (s1 and s2), not any of the variables declared after a constraint (s3).

substitution
  s2 |-> ?-s2-1
  s1 |-> #-s1_2-2

Expected behavior Substitutions shows all declared variables

Additional context Was debugging a complicated issue and I grouped declarations by section instead of putting them all at the top when I noticed this issue.

MeAmAnUsername commented 3 years ago

Thinking about it, this behavior could be fine if it is documented, it makes it possible to put the variables you care about at the top and ignore the rest:

resolve {v1 v2} // interesting variables
  true,
  { v3 v4 v5 v6} // don't care about these
  ... // constraints
AZWN commented 3 years ago

Statix test results only show the variables from the top-level existential constraint to prevent printing too many variables, because also constraints generated by rule application/existential constraints in rule bodies would otherwise be printed.

I can however think of a normalization that lifts all existential variables in a test to the top-level, which would print all variables in the tested constraint, but not in the rules.

MeAmAnUsername commented 2 years ago

This issue still has State-Needs-Clarification, so I assume you need clarification on the behavior I'd like to see. In my opinion the best option is the original description of this issue, i.e. all variables declared in resolve are printed, variables generated by normalization not. I don't think too many irrelevant variables is really an issue unless you are doing some truly complicated stuff, and if you still want to see the value of some function call you can just put it in a variable: {res_1} res_1@func(...).

AZWN commented 2 years ago

Haha, sometimes it also means that I need to make up my mind myself. In this case I think I agree, although I'm not going to distinguish between variables introduced by normalization, but by variables introduced in rules.