Skip to content

Commit

Permalink
fix #1038
Browse files Browse the repository at this point in the history
Expressions such as `[a: 1 2 3]` should be equivalent to
`[{a: 1}, 2, 3]` and not `[{a: 1, 2: 2, 3: 3}]`. Property shorthand,
including atomic identifiers/literals as shorthand for key-value pairs
with the atom as the key and value, should not work outside of braces.
  • Loading branch information
rhendric committed Oct 25, 2018
1 parent 29c9c51 commit bc1c188
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lexer.ls
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ exports <<<
add-implicit-indentation it
rewrite-blockless it
add-implicit-parentheses it
add-implicit-braces it
expand-literals it
add-implicit-braces it

This comment has been minimized.

Copy link
@pepkin88

pepkin88 Oct 29, 2018

Contributor

Hehe, I was going to post the exact same fix, you were faster :)

it.shift! if it.0?.0 is 'NEWLINE'
it

Expand Down
11 changes: 11 additions & 0 deletions test/literal.ls
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,17 @@ a = Array do
eq 2, a.length
eq 2, (Array 1: 2, 3).length

# [LiveScript#1038](https://github.com/gkz/LiveScript/issues/1038):
# More cases of not consuming shorthand properties.
a = [a: 1 2 3]
eq 3 a.length

fn = (x, y, z) -> z
eq 3 fn a: 1 2 3

e = try LiveScript.compile 'x = a: 1 2' catch e
eq "Parse error on line 1: Unexpected ','" e.message


# With leading comments.
obj =
Expand Down

0 comments on commit bc1c188

Please sign in to comment.