diff options
author | Jason Beetham <beefers331@gmail.com> | 2022-04-14 03:30:59 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 11:30:59 +0200 |
commit | dc4cc2dca53e3772efb3654a4ddbbe8350d1db43 (patch) | |
tree | 8943c5c8f677a2a9305182457a2baba8e0b914e9 | |
parent | ef7d7f24594b1ea560fbf25d3fa0d6c51122725f (diff) | |
download | Nim-dc4cc2dca53e3772efb3654a4ddbbe8350d1db43.tar.gz |
Fix string stream crashing when created on nimscript due to last fix (#19717)
-rw-r--r-- | lib/pure/streams.nim | 2 | ||||
-rw-r--r-- | tests/stdlib/tstreams.nim | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 84451f989..2ac6a82f1 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -1274,7 +1274,7 @@ else: # after 1.3 or JS not defined new(result) result.data = s - when defined(gcOrc) or defined(gcArc): + when declared(prepareMutation): prepareMutation(result.data) # Allows us to mutate using `addr` logic like `copyMem`, otherwise it errors. result.pos = 0 result.closeImpl = ssClose diff --git a/tests/stdlib/tstreams.nim b/tests/stdlib/tstreams.nim index d199037e3..6fda30f51 100644 --- a/tests/stdlib/tstreams.nim +++ b/tests/stdlib/tstreams.nim @@ -76,3 +76,7 @@ block: doAssert(ss.getPosition == 5) # haven't moved ss.setPosition(0) # Ensure we dont error with writing over literals on arc/orc #19707 ss.write("hello") + +static: # Ensure streams it doesnt break with nimscript on arc/orc #19716 + let s = newStringStream("a") + discard s.data |