-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typechecker: Bound expressions should only be evaluated once
Now Jakt inserts declarations to save the bound expressions before checking them, and uses the variable names to access the bound parts. This ensures that the original expression isn't run more than once.
- Loading branch information
Showing
3 changed files
with
159 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/// Expect: | ||
/// - output: "foo called\n" | ||
|
||
// Asserts that `foo()` is called only once. | ||
// Brought up by #1450. | ||
|
||
fn foo() -> i32? { | ||
println("foo called") | ||
return 1i32 | ||
} | ||
|
||
fn main() { | ||
if foo() is Some(x) { | ||
} | ||
} |