Commit c3b3a8b
authored
* fix Object.assign crashing when source is a non-table value
`{ ...(cond && obj) }` short-circuits to `false` when `cond` is falsy. JS
treats this as a no-op (Object.assign coerces primitives to wrapper objects
with no own enumerable properties), but `__TS__ObjectAssign` was iterating
every source unconditionally, so `pairs(false)` errored at runtime.
Skip non-table sources, matching the spec for null/undefined/primitive args.
* refactor __TS__ObjectAssign to emit cleaner Lua
Invert the type guard so it nests the spread loop instead of using `continue`,
which lowered to a `repeat ... until true` + `break` dance. Same behavior,
the bundled helper now reads like the hand-written original.
1 parent 5176fcd commit c3b3a8b
3 files changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
13 | 23 | | |
14 | 24 | | |
15 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
| |||
0 commit comments