-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support inferring the type of if-else based on the else branch (#762)
If we can't infer the type of the `then` branch but we can infer the type of the `else` branch, then use that type and check the `then` branch matches it.
- Loading branch information
Showing
2 changed files
with
73 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
val zeros : forall 'n, 'n >= 0 . implicit('n) -> bits('n) | ||
function zeros (n) = sail_zeros (n) | ||
|
||
function main() -> unit = { | ||
let b : bool = true; | ||
let _ = if b then 0x12 else zeros(); | ||
let _ = if b then zeros() else 0x12; | ||
let _ = if b then 1 else 2; | ||
|
||
let _ = if true then 0x12 else zeros(); | ||
let _ = if true then zeros() else 0x12; | ||
let _ = if true then 1 else 2; | ||
} |