Skip to content

Better error message for newbie mistake +: vs :+ #361

@sbarzowski

Description

@sbarzowski

I don't think this is actually very important, but it was a source of confusion at some point so here it is.

It's quite easy to write something like:

{x: {y: 1}} {x:+ { z: 2 }}

It doesn't work and error message is mildly confusing:

RUNTIME ERROR: Unary operator + does not operate on type object

It's worse on integer types (that I initially got a problem with), but I suppose this is not what +: was designed for anyway:

{x: 1} { x :+ 42}

It doesn't fail, but the result is not what I expected:

{
   "x": 42
}

I think it can be easily made better by lexing :+ as a single token. Then a much more friendly static error would appear:

Expected one of :, ::, :::, +:, +::, +:::, got: :+

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