forked from tact-lang/tact
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: typechecking of conditional expressions (tact-lang#394)
in the presense of subtyping
- Loading branch information
1 parent
0f65cfa
commit a59bf32
Showing
6 changed files
with
192 additions
and
8 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,12 @@ | ||
primitive Int; | ||
primitive Bool; | ||
|
||
fun foo1(x: Int?): Int { | ||
let cond: Bool = true; | ||
return cond ? 42 : x; | ||
} | ||
|
||
fun foo2(x: Int?): Int { | ||
let cond: Bool = true; | ||
return cond ? x : 42; | ||
} |
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,36 @@ | ||
primitive Int; | ||
primitive Bool; | ||
primitive Cell; | ||
|
||
fun foo1(x: Int?): Int? { | ||
let cond: Bool = true; | ||
return cond ? 42 : x; | ||
} | ||
|
||
fun foo2(x: Int?): Int? { | ||
let cond: Bool = true; | ||
return cond ? x : 42; | ||
} | ||
|
||
fun bar1(m: map<Int, Int>): map<Int, Int> { | ||
let cond: Bool = true; | ||
return cond ? null : m; | ||
} | ||
|
||
fun bar2(m: map<Int, Int>): map<Int, Int> { | ||
let cond: Bool = true; | ||
return cond ? m : null; | ||
} | ||
|
||
struct Bar { | ||
a: Cell?; | ||
} | ||
|
||
struct Baz { b: Int; } | ||
|
||
fun baz(x: Cell?): Bar { | ||
let cond: Bool = true; | ||
return Bar { | ||
a: cond ? Baz { b: 42 }.toCell() : x | ||
}; | ||
} |