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

viewing or editing a function with a long string concatenation expression produces unparseable code #1740

Closed
samgqroberts opened this issue Nov 2, 2020 · 4 comments

Comments

@samgqroberts
Copy link
Contributor

If I write this function:

multiLineText : Text
multiLineText =
  use Text ++
  "this is the first line" ++ 
  "this is the second line" ++
  "this is the third line" ++
  "this is the fourth line"

It will parse and typecheck just fine. If I add it to my codebase, then view it back out, ucm shows it to me like this:

.> view multiLineText

  multiLineText : Text
  multiLineText =
    use Text ++
       "this is the first line"
    ++ "this is the second line"
    ++ "this is the third line"
    ++ "this is the fourth line"

The ++ operators have been moved to the beginning of the lines. I get the exact same representation if I edit it back into my scratch file, but then if I simply save my scratch file without any further changes to the function, I get a parsing error:

.> 

  /home/sam/rummikub/scratch.u:5:3:
  unexpected ++
  expecting [, bang, binding, false, handle, if, lambda, let, namespace, quote, termLink, true, tuple, or typeLink
      5 |   ++ "this is the second line"

It looks like beginning the lines with the ++ operators confuses ucm, which raises the more general issue that ucm gave me back a code representation of a function that was not immediately parseable.

This may happen to many (every?) operators in long lines. I've tried this with &&:

multiLineBoolean : Boolean
multiLineBoolean =
  true && true && true && true && true && true && true && true && true && true && true && true && true

and found a similar issue when editing it back out:

.> view multiLineBoolean

  multiLineBoolean : Boolean
  multiLineBoolean =
    (((((((((((true && true) && true) && true) && true) && true) && true) && true) && true)
    &&
    true)
    &&
    true)
    &&
    true)
    &&
    true
.> 

  /home/sam/rummikub/scratch.u:14:3:
  unexpected &&
  expecting [, bang, binding, false, handle, if, lambda, let, namespace, quote, termLink, true, tuple, or typeLink
     14 |   &&
@pchiusano
Copy link
Member

Thanks for reporting, will take a look.

@pchiusano
Copy link
Member

/cc @atacratic

@atacratic
Copy link
Contributor

Dup of #1035 - I also hit this fairly often.

Thank you for the thorough report!

@samgqroberts
Copy link
Contributor Author

Ah, thanks @atacratic ! Also, TIL a new bit of lingo: "slurp"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants