-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes another effect inference bug [backport:1.6] (#19100)
* fixes another effect inference bug [backport:1.6] (cherry picked from commit fce89cb)
- Loading branch information
Showing
7 changed files
with
85 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
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,63 @@ | ||
discard """ | ||
cmd: "nim check --hints:off $file" | ||
nimout: '''tnestedprocs.nim(27, 8) Error: 'inner' can have side effects | ||
> tnestedprocs.nim(29, 13) Hint: 'inner' calls `.sideEffect` 'outer2' | ||
>> tnestedprocs.nim(26, 6) Hint: 'outer2' called by 'inner' | ||
tnestedprocs.nim(45, 8) Error: 'inner' can have side effects | ||
> tnestedprocs.nim(47, 13) Hint: 'inner' calls `.sideEffect` 'outer6' | ||
>> tnestedprocs.nim(44, 6) Hint: 'outer6' called by 'inner' | ||
tnestedprocs.nim(58, 41) Error: type mismatch: got <proc ()> but expected 'proc (){.closure, noSideEffect.}' | ||
Pragma mismatch: got '{..}', but expected '{.noSideEffect.}'. | ||
''' | ||
errormsg: "type mismatch: got <proc ()> but expected 'proc (){.closure, noSideEffect.}'" | ||
""" | ||
{.experimental: "strictEffects".} | ||
proc outer {.noSideEffect.} = | ||
proc inner(p: int) = | ||
if p == 0: | ||
outer() | ||
|
||
inner(4) | ||
|
||
outer() | ||
|
||
proc outer2 = | ||
proc inner(p: int) {.noSideEffect.} = | ||
if p == 0: | ||
outer2() | ||
|
||
inner(4) | ||
|
||
outer2() | ||
|
||
proc outer3(p: int) {.noSideEffect.} = | ||
proc inner(p: int) {.noSideEffect.} = | ||
if p == 0: | ||
p.outer3() | ||
|
||
inner(4) | ||
|
||
outer3(5) | ||
|
||
proc outer6 = | ||
proc inner(p: int) {.noSideEffect.} = | ||
if p == 0: | ||
outer6() | ||
|
||
inner(4) | ||
echo "bad" | ||
|
||
outer6() | ||
|
||
|
||
proc outer4 = | ||
proc inner(p: int) {.noSideEffect.} = | ||
if p == 0: | ||
let x: proc () {.noSideEffect.} = outer4 | ||
x() | ||
|
||
inner(4) | ||
|
||
outer4() |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
discard """ | ||
output: '''34''' | ||
joinable: false | ||
""" | ||
|
||
{.compile("cfunction.c", "-DNUMBER_HERE=34").} | ||
|