forked from nim-lang/Nim
-
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 nim-lang#13513 +% now gives correct values in semfold + VM
- Loading branch information
1 parent
986f9fc
commit 9be3835
Showing
3 changed files
with
32 additions
and
11 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,20 @@ | ||
template testAll(isSemFold: bool) = | ||
block: | ||
template test(T) = | ||
proc fun(): T {.gensym.} = | ||
when isSemFold: | ||
high(T) +% 1 | ||
else: | ||
let a = high(T) | ||
a +% 1 | ||
const a1 = fun() | ||
let a2 = fun() | ||
doAssert a1 <= high(T) | ||
doAssert $a1 == $a2 | ||
doAssert a1 == a2 | ||
test(int8) | ||
test(int16) | ||
test(int32) | ||
|
||
testAll(true) # will call semfold.nim `of mAddU:` | ||
testAll(false) # will call vm.nim `of opcNarrowU:` |