-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy var flags when duplicating local variables (#11803)
* copy var flags when duplicating Also don't unroll loops that have static vars closes #11800 * hoist static locals when unrolling loops see #11800 * hoist all var declarations when unrolling loops * awkwardly deal with captured locals * clean up a bit, but don't hoist non-statics after all * don't need this now * remove test
- Loading branch information
Showing
6 changed files
with
112 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package issues; | ||
|
||
class Issue11800 { | ||
@:js(' | ||
++issues_Issue11800.test_a; | ||
++issues_Issue11800.test_b; | ||
++issues_Issue11800.test_a; | ||
++issues_Issue11800.test_b; | ||
') | ||
static function test() { | ||
static var a = 0; | ||
|
||
for (i in 0...3) { | ||
switch i { | ||
case n if (n < 2): | ||
use(++a); | ||
static var b = 0; | ||
use(++b); | ||
case _: | ||
} | ||
} | ||
} | ||
|
||
static function use(v:Int) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package unit.issues; | ||
|
||
class Issue11800 extends unit.Test { | ||
public function test() { | ||
static var a = 0; // Works. | ||
var buf = new StringBuf(); | ||
function append(v:Int) { | ||
buf.add(Std.string(v)); | ||
} | ||
for (i in 0...3) { | ||
switch i { | ||
case n if (n < 2): | ||
append(++a); | ||
static var b = 0; // Not static. | ||
append(++b); // Always `1`. | ||
case _: | ||
} | ||
} | ||
eq("1122", buf.toString()); | ||
} | ||
} |