Skip to content

Capturing bind with symbolic name doesn't work in ability constructor match #5660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ceedubs opened this issue Apr 22, 2025 · 0 comments
Open
Labels

Comments

@ceedubs
Copy link
Contributor

ceedubs commented Apr 22, 2025

Describe and demonstrate the bug

fresh/main> builtins.merge

  Done.

In the following code, the user-provided function can be captured as == by using parentheses (==):

ensureEqBy : (a -> a -> Boolean) -> a -> a -> ()
ensureEqBy (==) a1 a2 = if a1 == a2 then () else bug ("not equal", a1, a2)

ability EnsureEq where
  ensureEqBy2 : (a -> a -> Boolean) -> a -> a -> ()
  Loading changes detected in scratch.u.

  I found and typechecked these definitions in scratch.u. If you
  do an `add` or `update`, here's how your codebase would
  change:

    ⍟ These new definitions are ok to `add`:
    
      ability EnsureEq
      ensureEqBy : (a ->{g1} a ->{g} Boolean)
                   -> a
                   -> a
                   ->{g1, g} ()

However, the same does not work in an ability constructor match:

EnsureEq.run : '{g, EnsureEq} r -> {g} r
EnsureEq.run =
  go thunk = handle !thunk with cases
    { r } -> r
    { ensureEqBy2 (==) a1 a2 -> k } ->
      if a1 == a2 then () else bug ("not equal", a1, a2)
      go k
  go

🛑

The transcript failed due to an error in the stanza above. The error is:

I got confused here:

    5 |     { ensureEqBy2 (==) a1 a2 -> k } ->


I was surprised to find a ( here.
I was expecting one of these instead:

* @

Environment (please complete the following information):

  • ucm --version bc7e65d built on 04/22/2025
@ceedubs ceedubs added the bug label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant