Skip to content

Commit 7fc1a2e

Browse files
committed
fix(js): os: just import causes not compile
1 parent 48d0fc3 commit 7fc1a2e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/pylib/Lib/os_impl/posix_like/open_close.nim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import std/os
44
import ../common
55
import ../consts
66

7+
type NotImplForNonNode = object of RootEffect
8+
79
when defined(js):
10+
template notImpl = raise newException(NotImplementedError, "")
811
when defined(nodejs):
912
proc openSync(path: cstring, flags, mode: cint): cint{.importNode(fs, openSync).}
1013
# in fact flags, mode is optional and accepts cstring, but we don't need such variants here
@@ -17,10 +20,11 @@ when defined(js):
1720
catchJsErrAsCode msg, closeSync(fd)
1821
else:
1922
const openNotImpl = "not impl for non-nodejs JS engine"
20-
proc openSync(path: cstring, flags, mode: cint): cint{.error:
21-
openNotImpl.}
23+
proc openSync(path: cstring, flags, mode: cint): cint{.tags: [NotImplForNonNode].} =
2224
# XXX: Deno.openSync returns FsFile instead of integer
23-
proc c_close(fd: cint, msg: var string): int{.error: openNotImpl.}
25+
notImpl
26+
proc c_close(fd: cint): int{.tags: [NotImplForNonNode].} = notImpl
27+
proc c_close(fd: cint, msg: var string): int{.tags: [NotImplForNonNode].} = notImpl
2428

2529
else:
2630
let EINTR{.importc, header: "<errno.h>".}: cint
@@ -55,7 +59,7 @@ else:
5559
let DEFAULT_DIR_FD{.importc, nodecl.}: cint
5660

5761

58-
proc open*(path: PathLike, flags: int, mode=0o777, dir_fd = -1): int =
62+
proc open*(path: PathLike, flags: int, mode=0o777, dir_fd = -1): int{.forbids: [NotImplForNonNode].} =
5963
## `dir_fd` is ignored under Windows
6064
sys.audit("open", path, mode, flags)
6165
when defined(js):

0 commit comments

Comments
 (0)