fix #19680; check if stderr is static (#19709)

This commit is contained in:
flywind 2022-04-12 15:48:48 +08:00 • committed by GitHub
commit 26bcf18f91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -1479,7 +1479,7 @@ proc checkCanEval(c: PCtx; n: PNode) =
# proc foo() = var x ... # proc foo() = var x ...
let s = n.sym let s = n.sym
if {sfCompileTime, sfGlobal} <= s.flags: return if {sfCompileTime, sfGlobal} <= s.flags: return
if s.importcCondVar: return if compiletimeFFI in c.config.features and s.importcCondVar: return
if s.kind in {skVar, skTemp, skLet, skParam, skResult} and if s.kind in {skVar, skTemp, skLet, skParam, skResult} and
not s.isOwnedBy(c.prc.sym) and s.owner != c.module and c.mode != emRepl: not s.isOwnedBy(c.prc.sym) and s.owner != c.module and c.mode != emRepl:
# little hack ahead for bug #12612: assume gensym'ed variables # little hack ahead for bug #12612: assume gensym'ed variables

View file

@ -46,3 +46,13 @@ echo value
var ys = @[4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2] var ys = @[4.1, 5.6, 7.2, 1.7, 9.3, 4.4, 3.2]
#var x = int(ys.high / 2) #echo ys[x] # Works #var x = int(ys.high / 2) #echo ys[x] # Works
echo ys[int(ys.high / 2)] # Doesn't work echo ys[int(ys.high / 2)] # Doesn't work
# bug #19680
var here = ""
when stderr is static:
doAssert false
else:
here = "works"
doAssert here == "works"