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.
std/dynlib: fix
loadLibPatterns
having unknown effects (nim-lang#1237)
## Summary The `loadLibPatterns` procedure was erroneously inferred to have unknown effects (`RootEffect`), making it unusable in `.tags: []` procedures. This is now fixed. ## Details `loadLibPatterns` calls the at-that-point forwarded procedure `loadLib`, so effect inference falls back to assume that `loadLibPatterns` can have effects. Since `loadLib`, as well as the other forward-declared procedures, don't have effects in practice, this is now explicitly specified on the forward declarations.
- Loading branch information
Showing
2 changed files
with
27 additions
and
4 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,21 @@ | ||
discard """ | ||
targets: c | ||
action: compile | ||
""" | ||
|
||
import std/dynlib | ||
|
||
# ensure that the dynlib procedures are GC safe and don't have effects | ||
proc dynlibProcsHaveNoEffects1() {.gcsafe, raises: [], tags: [].} = | ||
discard loadLib("") | ||
discard loadLib() | ||
unloadLib(nil) | ||
discard symAddr(nil, nil) | ||
|
||
var candidates: seq[string] | ||
libCandidates("", candidates) | ||
|
||
discard loadLibPattern("") | ||
|
||
proc dynlibProcsHaveNoEffects2() {.gcsafe, tags: [].} = | ||
discard checkedSymAddr(nil, nil) |