Last active
December 4, 2017 14:58
-
-
Save wbbradley/6dc1ab1e12ce4312c83cd33012eb721b to your computer and use it in GitHub Desktop.
Zion: Refining Types in Short-circuited Logical Expressions
This file contains hidden or 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
module _ | |
def gimme_bool() bool | |
return true | |
def main() | |
static_print(7) | |
static_print("hello") | |
static_print(gimme_bool()) | |
static_print(gimme_bool() ? "foo" : 4.5) | |
static_print(gimme_bool() and 9) | |
static_print(gimme_bool() and 9 or 200) | |
static_print(true and 100) | |
static_print(false and 100) | |
static_print(true or 100) | |
static_print(false or 100) |
This file contains hidden or 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
$ zion compile condition_refinement.zion |
This file contains hidden or 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
condition_refinement.zion|8 col 15| info: 7 : int | |
condition_refinement.zion|9 col 15| info: "hello" : str | |
condition_refinement.zion|10 col 25| info: gimme_bool() : bool | |
condition_refinement.zion|11 col 25| info: gimme_bool() ? "foo" : 4.5 : (or str float) | |
condition_refinement.zion|12 col 28| info: (gimme_bool() and 9) : (or int false) | |
condition_refinement.zion|13 col 41| info: ((gimme_bool() and 9) or 200) : int | |
condition_refinement.zion|14 col 20| info: (true and 100) : int | |
condition_refinement.zion|15 col 21| info: (false and 100) : false | |
condition_refinement.zion|16 col 20| info: (true or 100) : true | |
condition_refinement.zion|17 col 21| info: (false or 100) : int |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment