Skip to content

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

@samgqroberts

Description

@samgqroberts

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 |   &&

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions