diff options
author | bptato <nincsnevem662@gmail.com> | 2023-08-01 19:05:45 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-08-01 19:37:48 +0200 |
commit | af3dbce840d0d0956663ffb20012329a4c22d5dd (patch) | |
tree | da3c2bad567d9b08f585cbc973aac61ef4eb05ae /src/io | |
parent | cab49aa0952c24941bcfb9a5b483f796158bf373 (diff) | |
download | chawan-af3dbce840d0d0956663ffb20012329a4c22d5dd.tar.gz |
Fixes & workarounds to compile on Nim 2.0.0
* Import punycode, as it has been removed from stdlib. * Fix some syntax errors * Apparently you can no longer compare distinct pointers with nil. Add explicit comparisons with typeof(nil) instead. * htmlparser: rename _ to other, as semantics of _ have changed. (Quite a shame, it looked better with _. Oh well.) * Explicitly specify mm:refc, as the browser OOMs with orc for some reason. Confirmed to compile & run on 2.0.0, 1.6.14, 1.6.12, 1.6.10 and 1.6.8. (<1.6.8 it's broken & wontfix.)
Diffstat (limited to 'src/io')
-rw-r--r-- | src/io/promise.nim | 3 | ||||
-rw-r--r-- | src/io/response.nim | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/io/promise.nim b/src/io/promise.nim index ba1dad07..ee4f0654 100644 --- a/src/io/promise.nim +++ b/src/io/promise.nim @@ -22,6 +22,9 @@ type tab: Table[int, EmptyPromise] opaque*: pointer +proc newPromise*[T](): Promise[T] = + return Promise[T]() + proc newPromiseMap*(opaque: pointer): PromiseMap = return PromiseMap( opaque: opaque diff --git a/src/io/response.nim b/src/io/response.nim index 6a5a5bbf..b64f1504 100644 --- a/src/io/response.nim +++ b/src/io/response.nim @@ -49,7 +49,7 @@ proc close*(response: Response) {.jsfunc.} = proc text*(response: Response): Promise[Result[string, JSError]] {.jsfunc.} = if response.bodyRead == nil: - let p = Promise[Result[string, JSError]]() + let p = newPromise[Result[string, JSError]]() let err = Result[string, JSError] .err(newTypeError("Body has already been consumed")) p.resolve(err) |