Skip to content
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

use parsing is weird? #5487

Open
aryairani opened this issue Dec 8, 2024 · 2 comments
Open

use parsing is weird? #5487

aryairani opened this issue Dec 8, 2024 · 2 comments
Labels

Comments

@aryairani
Copy link
Contributor

Describe and demonstrate the bug

scratch/main> builtins.merge
addOne : Nat -> Nat
addOne n1 =
  use Nat +
    n1 + 1

-- parses the same as:

addOne' : Nat -> Nat
addOne' n1 = 
  use Nat + n1 +
  1

-- when it was meant to parse as:

addOne'' : Nat -> Nat
addOne'' n =
  use Nat +
  n + 1


> addOne 5
> addOne' 5
> addOne'' 5
  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`:
    
      addOne   : Nat -> Nat
      addOne'  : Nat -> Nat
      addOne'' : Nat -> Nat

  Now evaluating any watch expressions (lines starting with
  `>`)... Ctrl+C cancels.

    17 | > addOne 5
           ⧩
           1

    18 | > addOne' 5
           ⧩
           1

    19 | > addOne'' 5
           ⧩
           6

UCM should at least give an error, not split the use line arbitrarily at the nat literal.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • 0.5.29

Additional context

@aryairani aryairani added the bug label Dec 8, 2024
@aryairani
Copy link
Contributor Author

reported by @Ash-the-practical-programmer and @kylegoetz

@kylegoetz
Copy link
Contributor

I also checked

addOne n1 =
  use Nat +
    n1 + 1 |> (_ -> Debug.trace "n1" n1)

to see if n1 was possibly somehow a valid hash for something in Nat, but UCM reports

I couldn't figure out what Nat.n1 refers to here:
  
      4 |     n1 + 1 |> (_ -> Debug.trace "n1" n1)

so it looks like it is just no error on non-existent import

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

2 participants