Skip to content

Commit 1f9cac1

Browse files
authored
Enable macros to use certain things from the OS module when the target OS is not supported (#24639)
Essentially this PR removes the `{.error.}` pragmas littered around in the OS module and submodules which prevents them from being imported if the target OS is not supported. This made it impossible to use certain supported features of the OS module in macros from a supported host OS. Instead of the `{.error.}` pragmas the `oscommon` module now has a constant `supportedSystem` which is false in the cases where the `{.error.}` pragmas where generated. All procedures which can't be run by macros is also not declared when `supportedSystem` is false. It would be possible to create dummy versions of the omitted functions with an `{.error.}` pragma that would trigger upon their use, but this is currently not done. This properly fixes #19414
1 parent 67f9bc2 commit 1f9cac1

File tree

9 files changed

+768
-767
lines changed

9 files changed

+768
-767
lines changed

compiler/vmops.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ proc registerAdditionalOps*(c: PCtx) =
263263
wrap2si(readLines, ioop)
264264
systemop getCurrentExceptionMsg
265265
systemop getCurrentException
266-
registerCallback c, "stdlib.osdirs.staticWalkDir", proc (a: VmArgs) {.nimcall.} =
266+
registerCallback c, "stdlib.staticos.staticWalkDir", proc (a: VmArgs) {.nimcall.} =
267267
setResult(a, staticWalkDirImpl(getString(a, 0), getBool(a, 1)))
268268
registerCallback c, "stdlib.staticos.staticDirExists", proc (a: VmArgs) {.nimcall.} =
269269
setResult(a, dirExists(getString(a, 0)))

0 commit comments

Comments
 (0)