metaborg / stratego

Apache License 2.0
10 stars 6 forks source link

map(try(s)) does not report a cast inserted for s #27

Open molenzwiebel opened 2 years ago

molenzwiebel commented 2 years ago

Describe the bug Using map(try(s)) for some strategy s will not report a cast insertion, even if there is a cast inserted. This is unlike filter(s), which seems to behave differently and may not even insert a cast.

Project Used inside a Spoofax 3 source project.

Versions metaborg/devenv@fe137453e62d61da3e1e5b172b6659f038815aa0

To Reproduce

signature
  sorts Test
  constructors
    Foo : Test
    Bar : Test

rules
  run = ![Foo(), Bar()]; issue

  issue :: List(Test) -> ?
  issue = map(try(do-something-with-bar)) // fails, no cast message
  // issue = filter(do-something-with-bar) // succeeds, no cast message (and seemingly no cast needed)

  do-something-with-bar: Bar() -> ()
    with debug(!"Got a bar: ")

Observed behaviour

Exception during evaluation: Cannot cast the following term from Tuple to Test:
()

Expected behaviour Ideally, this succeeds as this is perfectly fine in Stratego 1. If that is not possible, a message that a cast is being inserted in the map(try(s)).