sweet-js/sweet-core

Cannot use rest/spread operator in syntax template for all valid expressions

gabejohnson opened this issue · 0 comments

As noted #715

import { fromPunctuator } from 'sweet.js/helpers' for syntax;

syntax $$ = (ctx) => {
  var dummy = #`dummy`.get(0);
  return #`${fromPunctuator(dummy, '...')}${ctx}`;
};

function foo(args){}
foo( $$ [0] );

fails with Error: expecting a , punctuator [ 0 ], but

function foo(args){}
foo( ... [0] );

is fine.

Same with

let [$$ x] = [1]; // Error: unexpected token __x__

but this is fine

let x = [$$ [0]];

This may be related to #716. Hopefully it'll come out in the wash.