Skip to content

[JS] invalid JS syntax emitted when negating negative literals in computational expressionΒ #4251

@goswinr

Description

@goswinr

It took me a while to track this down.
I got an Invalid left-hand side expression in prefix operation exception from my JS entry file, not the actual location of the problem.

It comes down to this:
In computational expressions, the float literal gets inlined and the negate sign is added twice

let f x  = x

[
  let x = -5.0  
  f (-x) 
]
|> ignore

This emits --5 , which is invalid JS.

see REPL

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions