Skip to content

Commit

Permalink
Ensure string interpolations with empty prefixes have raw values.
Browse files Browse the repository at this point in the history
Without this the string node that is the left of the ConcatOp has no
raw value, which is unexpected when parsing with `raw: true`.
  • Loading branch information
eventualbuddha committed Jan 22, 2015
1 parent b31ccfb commit 9fdedda
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/parser.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/grammar.pegcoffee
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
expr

createInterpolation = (es) ->
init = new CS.String('').g()
init = new CS.String('').g().r('')
foldl ((memo, s) ->
if s instanceof CS.String
left = memo
Expand Down
4 changes: 4 additions & 0 deletions test/parser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ suite 'Parser', ->
eq 'aaaaaa', ast.body.statements[0].left.left.raw
eq 'cccccc', ast.body.statements[0].right.raw

test 'empty string interpolation prefix', ->
ast = parse '"#{0}"', raw: yes
eq '', ast.body.statements[0].left.raw

suite 'position/offset preservation', ->

test 'basic indentation', ->
Expand Down

0 comments on commit 9fdedda

Please sign in to comment.