Skip to content

Commit

Permalink
Fix top-level origin tracking in Statix injection explication
Browse files Browse the repository at this point in the history
...for new projects that caused the top-level term of an AST
to be missing when a Stratego strategy is applied
to an analyzed AST in an SPT test.
  • Loading branch information
Virtlink committed Jan 21, 2021
1 parent a0de695 commit 7cd7e32
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
21 changes: 19 additions & 2 deletions source/langdev/meta/lang/statix/signature-generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ symbol (as specified in ``Syntax.esv``). For example, in ``trans/analysis.str``:
rules
editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"static-semantics", "programOk")
pre-analyze = explicate-injections-MyLang-Start
post-analyze = implicate-injections-MyLang-Start
pre-analyze = origin-track-forced(explicate-injections-MyLang-Start)
post-analyze = origin-track-forced(implicate-injections-MyLang-Start)
Expand Down Expand Up @@ -266,3 +266,20 @@ Clean fails with an error such as this:
You are using the old ``sdf2table: c``. Change this in ``metaborg.yaml`` into
``sdf2table: java``.


SPT analysis tests calling Stratego strategies fail
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
An SPT test can run an arbitrary Stratego strategy on an analyzed AST
and compare the results with the expected AST. If the origin of the is not
tracked properly, the root constructor of the resulting analyzed AST will
be missing and the comparison will fail.

To fix this, ensure the ``pre-analyze`` and ``post-analyze`` strategies in
``analysis.str`` call ``origin-track-forced``:

.. code-block:: stratego
pre-analyze = origin-track-forced(explicate-injections-MyLang-Start)
post-analyze = origin-track-forced(implicate-injections-MyLang-Start)
11 changes: 10 additions & 1 deletion source/release/migrate/vnext.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@

# Spoofax vNext Migration Guide

This is a stub for the migration guide of Spoofax vNext.
This is a stub for the migration guide of Spoofax vNext.


## Statix Injection Explication
There was an issue with Statix injection explication where the origin of the top-level term was lost and this caused SPT tests of Stratego strategies on analyzed ASTs to fail. Fix this by wrapping the bodies of the `pre-analyze` and `post-analyze` strategies in `analyze.str` with `origin-track-forced`, like this:

pre-analyze = origin-track-forced(explicate-injections-MyLang-Start)
post-analyze = origin-track-forced(implicate-injections-MyLang-Start)

This is already fixed in new projects.
4 changes: 4 additions & 0 deletions source/release/note/vnext.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ See the corresponding :ref:`migration guide <vnext-migration-guide>` for migrati

Changes
-------

* Fixed origin tracking in Statix injection explication for new projects
that caused the top-level term of an analyzed AST to be missing
when applying a Stratego strategy in an SPT test.

0 comments on commit 7cd7e32

Please sign in to comment.