summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-12 16:20:10 +0800
committerGitHub <noreply@github.com>2020-11-12 09:20:10 +0100
commit1f9bf43100f7236d8ccbcaa14c43bc18f7e6e5d8 (patch)
tree9e674a5f93079fe98cb00e188fb5709301f23dc7 /compiler
parent826e62953faa1f6cd9bac582246186935af4b8e6 (diff)
downloadNim-1f9bf43100f7236d8ccbcaa14c43bc18f7e6e5d8.tar.gz
fix #14157 (#15877)
* fix #14157

* Update compiler/jsgen.nim

* add changelog

* Update compiler/jsgen.nim

* Update tests/js/tmodify_cstring.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/jsgen.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 87021de11..357e18000 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -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.skipTypes(abstractInst).kind == tyCString:
+    localError(p.config, x.info, "cstring doesn't support `[]=` operator")
+
   gen(p, x, a)
   genLineDir(p, y)
   gen(p, y, b)