parent
13251c2ac9
commit
ca9c74391a
2 changed files with 26 additions and 3 deletions
|
|
@ -725,9 +725,12 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
|
||||||
if v.kind == skLet and sfImportc notin v.flags and (strictDefs notin c.features or not isLocalSym(v)):
|
if v.kind == skLet and sfImportc notin v.flags and (strictDefs notin c.features or not isLocalSym(v)):
|
||||||
localError(c.config, a.info, errLetNeedsInit)
|
localError(c.config, a.info, errLetNeedsInit)
|
||||||
if sfCompileTime in v.flags:
|
if sfCompileTime in v.flags:
|
||||||
|
if a.kind != nkVarTuple:
|
||||||
var x = newNodeI(result.kind, v.info)
|
var x = newNodeI(result.kind, v.info)
|
||||||
x.add result[i]
|
x.add result[i]
|
||||||
vm.setupCompileTimeVar(c.module, c.idgen, c.graph, x)
|
vm.setupCompileTimeVar(c.module, c.idgen, c.graph, x)
|
||||||
|
else:
|
||||||
|
localError(c.config, a.info, "cannot destructure to compile time variable")
|
||||||
if v.flags * {sfGlobal, sfThread} == {sfGlobal}:
|
if v.flags * {sfGlobal, sfThread} == {sfGlobal}:
|
||||||
message(c.config, v.info, hintGlobalVar)
|
message(c.config, v.info, hintGlobalVar)
|
||||||
if {sfGlobal, sfPure} <= v.flags:
|
if {sfGlobal, sfPure} <= v.flags:
|
||||||
|
|
|
||||||
20
tests/misc/t11634.nim
Normal file
20
tests/misc/t11634.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
discard """
|
||||||
|
action: reject
|
||||||
|
nimout: '''
|
||||||
|
t11634.nim(20, 7) Error: cannot destructure to compile time variable
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
type Foo = ref object
|
||||||
|
val: int
|
||||||
|
|
||||||
|
proc divmod(a, b: Foo): (Foo, Foo) =
|
||||||
|
(
|
||||||
|
Foo(val: a.val div b.val),
|
||||||
|
Foo(val: a.val mod b.val)
|
||||||
|
)
|
||||||
|
|
||||||
|
block:
|
||||||
|
let a {.compileTime.} = Foo(val: 2)
|
||||||
|
let b {.compileTime.} = Foo(val: 3)
|
||||||
|
let (c11634 {.compileTime.}, d11634 {.compileTime.}) = divmod(a, b)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue