-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42166 from mindula/fix-crash
Fix compiler crash caused by functions with infinite while loops
- Loading branch information
Showing
3 changed files
with
100 additions
and
14 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
81 changes: 81 additions & 0 deletions
81
...a-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-infinite.bal
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,81 @@ | ||
const TRUE = true; | ||
|
||
function testWhileStatementWithEndlessLoop() returns int { | ||
int x = 1; | ||
while true { | ||
x += 1; | ||
} | ||
} | ||
|
||
function testWhileStatementWithEndlessLoop2() returns int|never { | ||
int x = 1; | ||
while TRUE { | ||
x += 1; | ||
} | ||
} | ||
|
||
function testWhileStatementWithEndlessLoop3() returns int { | ||
int x = 1; | ||
while true { | ||
while true { | ||
while true { | ||
x += 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function testWhileStatementWithEndlessLoop4() returns int { | ||
int x = 0; | ||
while true { | ||
x += 1; | ||
if (x == 50) { | ||
// Intentionally no break statement | ||
} | ||
} | ||
} | ||
|
||
function testInfiniteLoopWhileStatementInWorker() returns future<int> { | ||
worker name returns int { | ||
while true { | ||
|
||
} | ||
} | ||
return name; | ||
} | ||
|
||
function testInfiniteLoopWhileStatementInAnonymousFunction() { | ||
function() returns int fn = function () returns int { | ||
while true { | ||
|
||
} | ||
}; | ||
_ = fn(); | ||
} | ||
|
||
|
||
function testInfiniteLoopWhileStatementInConditionalStatement(int x) returns int { | ||
if x > 10 { | ||
while true { | ||
|
||
} | ||
} else { | ||
while true { | ||
|
||
} | ||
} | ||
} | ||
|
||
client class MyClientClass { | ||
resource function accessor path() returns int { | ||
while true { | ||
|
||
} | ||
} | ||
|
||
remote function testInfiniteLoopWhileStatementInRemote() returns int { | ||
while true { | ||
|
||
} | ||
} | ||
} |