sweet-core icon indicating copy to clipboard operation
sweet-core copied to clipboard

Transpilation issues

Open KiaraGrouwstra opened this issue 8 years ago • 2 comments

Here are some issues I encountered when running previously working code through Sweet (babel settings identical):

// PARSING ERRORS:
let k = 'foo';
let a = { [k]: true }
// Missing case in fields: ComputedPropertyName
let { foo: foo } = { bar: 'bar' };
// not implemented yet for: BindingPropertyProperty
let hi = (
  /* line-break */
) => {}
// cannot get the val of a delimiter
function baz(x) { return ``; };
// Cannot read property 'startLocation' of undefined
let { bar = Math.random(1) } = { bar: 'bar' };
// Cannot read property 'typeName' of undefined
let str = `${Math.random(1)}`;
// Cannot read property 'typeName' of undefined
[...[]]
// Cannot read property 'type' of null

// INCORRECT TRANSPILATION (transpilation runs but the resulting code isn't right):
let ns = { cls: class tmp {} };
let obj = new ns.cls();
// ends up as `new ns().cls()`, triggering:
// TypeError: ns_5109 is not a constructor in [null]
function fn(a, b = a) {}
// ReferenceError: a is not defined
[...[], x]
// ends up as `[undefined, x]` instead of `[x]`

Edit: added 2 more. Do let me know if you'd prefer a dozen separate issues...

KiaraGrouwstra avatar Mar 31 '16 02:03 KiaraGrouwstra

I checked some of these out and a few are fixed. Here's what's still broken:

// PARSING ERRORS:
let hi = (
  /* line-break */
) => {}
// Error: not a valid expression
// __=>__ { }
let { bar = Math.random(1) } = { bar: 'bar' };
// Cannot read property 'typeName' of undefined
let str = `${Math.random(1)}`;
// Cannot read property 'typeName' of undefined

// INCORRECT TRANSPILATION (transpilation runs but the resulting code isn't right):
function fn(a, b = a) {}
// compiles to function fn(a_0, b_1 = a) {}
// ReferenceError: a is not defined
[...[], x]
// ends up as `[...[],, x]` evaluating to `[undefined, x]` instead of `[x]`

I think the last one is related to #605.

gabejohnson avatar Jan 19 '17 16:01 gabejohnson

Great to see it's getting better, thanks for the response! :)

KiaraGrouwstra avatar Jan 19 '17 16:01 KiaraGrouwstra