fixes #11048
This commit is contained in:
parent
14fc7437c3
commit
5bdab044f5
2 changed files with 3 additions and 10 deletions
|
|
@ -808,18 +808,15 @@ proc genFieldCheck(p: BProc, e: PNode, obj: Rope, field: PSym) =
|
||||||
v.r.add(".")
|
v.r.add(".")
|
||||||
v.r.add(disc.sym.loc.r)
|
v.r.add(disc.sym.loc.r)
|
||||||
genInExprAux(p, it, u, v, test)
|
genInExprAux(p, it, u, v, test)
|
||||||
let id = nodeTableTestOrSet(p.module.dataCache,
|
let strLit = genStringLiteral(p.module, newStrNode(nkStrLit, field.name.s))
|
||||||
newStrNode(nkStrLit, field.name.s), p.module.labels)
|
|
||||||
let strLit = if id == p.module.labels: genStringLiteralDataOnly(p.module, field.name.s, e.info)
|
|
||||||
else: p.module.tmpBase & rope(id)
|
|
||||||
if op.magic == mNot:
|
if op.magic == mNot:
|
||||||
linefmt(p, cpsStmts,
|
linefmt(p, cpsStmts,
|
||||||
"if ($1) #raiseFieldError($2);$n",
|
"if ($1) #raiseFieldError($2);$n",
|
||||||
[rdLoc(test), genStringLiteralFromData(p.module, strLit, e.info)])
|
[rdLoc(test), strLit])
|
||||||
else:
|
else:
|
||||||
linefmt(p, cpsStmts,
|
linefmt(p, cpsStmts,
|
||||||
"if (!($1)) #raiseFieldError($2);$n",
|
"if (!($1)) #raiseFieldError($2);$n",
|
||||||
[rdLoc(test), genStringLiteralFromData(p.module, strLit, e.info)])
|
[rdLoc(test), strLit])
|
||||||
|
|
||||||
proc genCheckedRecordField(p: BProc, e: PNode, d: var TLoc) =
|
proc genCheckedRecordField(p: BProc, e: PNode, d: var TLoc) =
|
||||||
if optFieldCheck in p.options:
|
if optFieldCheck in p.options:
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,6 @@ proc genStringLiteralDataOnly(m: BModule; s: string; info: TLineInfo): Rope =
|
||||||
else:
|
else:
|
||||||
localError(m.config, info, "cannot determine how to produce code for string literal")
|
localError(m.config, info, "cannot determine how to produce code for string literal")
|
||||||
|
|
||||||
proc genStringLiteralFromData(m: BModule; data: Rope; info: TLineInfo): Rope =
|
|
||||||
result = ropecg(m, "((#NimStringDesc*) &$1)",
|
|
||||||
[data])
|
|
||||||
|
|
||||||
proc genNilStringLiteral(m: BModule; info: TLineInfo): Rope =
|
proc genNilStringLiteral(m: BModule; info: TLineInfo): Rope =
|
||||||
result = ropecg(m, "((#NimStringDesc*) NIM_NIL)", [])
|
result = ropecg(m, "((#NimStringDesc*) NIM_NIL)", [])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue