Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Nov 7, 2020
1 parent fa5f225 commit bc49302
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/ccgstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,11 @@ proc genAsgn(p: BProc, e: PNode, fastAsgn: bool) =
else:
let le = e[0]
let ri = e[1]

# disable `[]=` for cstring
if le.kind == nkBracketExpr and le.len >= 2 and le[0].typ.kind == tyCString:
localError(p.config, le.info, "cstring doesn't support `[]=` operator!")

var a: TLoc
discard getTypeDesc(p.module, le.typ.skipTypes(skipPtrs), skVar)
initLoc(a, locNone, le, OnUnknown)
Expand Down
4 changes: 4 additions & 0 deletions compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,10 @@ proc genAsgnAux(p: PProc, x, y: PNode, noCopyNeeded: bool) =
var a, b: TCompRes
var xtyp = mapType(p, x.typ)

# disable `[]=` for cstring
if x.kind == nkBracketExpr and x.len >= 2 and x[0].typ.kind == tyCString:
localError(p.config, x.info, "cstring doesn't support `[]=` operator!")

gen(p, x, a)
genLineDir(p, y)
gen(p, y, b)
Expand Down

0 comments on commit bc49302

Please sign in to comment.