Commit 99f5dae
committed
Keep a preserved name and a self reference on the vararg original
Two ways a generated copy could take over something that belongs only to the
original it was copied from.
A preserved name is part of the map's Warcraft-facing API, set by
@preserveName and by ExecuteFunc. The copy inherits the flag, and because it
also shares the original's trace, collectPredefinedNames resets both to the
same source name: the emitted Lua then defines that name twice and the later
definition wins. ExecuteFunc makes this easy to reach, since it marks its
target preserved and emits a zero-argument call, which is exactly what makes
a copy. The flag is now dropped from copies on Lua, where the original is
retained and keeps the name that external code calls.
The other is the reference case of the recursion fix. ReferenceRewritingCopy
retargets a function's own references, and the repair visitor undid that for
calls but not for function references, so a self reference inside a copy kept
naming the copy: registering it as a callback would invoke a fixed-arity body
at an arity nobody checked. Those two node types are the only ones the copy
retargets that name a function at all, so the visitor now covers the pair
rather than the reported half. Lua only, because nothing redirects a
reference afterwards and only that target keeps the original; on Jass it is
removed and the reference would dangle.
Jass keeps both flags and both reference kinds exactly as before.1 parent 83f361d commit 99f5dae
2 files changed
Lines changed: 58 additions & 7 deletions
File tree
- de.peeeq.wurstscript/src
- main/java/de/peeeq/wurstscript/translation/imtranslation
- test/java/tests/wurstscript/tests
Lines changed: 25 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
214 | 216 | | |
215 | 217 | | |
216 | 218 | | |
| |||
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
222 | 235 | | |
223 | 236 | | |
224 | 237 | | |
| |||
266 | 279 | | |
267 | 280 | | |
268 | 281 | | |
269 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
270 | 287 | | |
271 | 288 | | |
272 | | - | |
273 | | - | |
| 289 | + | |
| 290 | + | |
274 | 291 | | |
| 292 | + | |
275 | 293 | | |
276 | 294 | | |
277 | 295 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2201 | 2201 | | |
2202 | 2202 | | |
2203 | 2203 | | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
2204 | 2237 | | |
2205 | 2238 | | |
2206 | 2239 | | |
| |||
0 commit comments