diff options
author | metagn <metagngn@gmail.com> | 2023-05-02 12:13:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-02 11:13:38 +0200 |
commit | c2bcfd8cd908265c358c60c4da137783b10a8549 (patch) | |
tree | 55b4d8b1efae6e820c88f0118ce9c96e62451c7a /compiler | |
parent | afc30ca87948c11f603f6686d4b10d3dcc27776a (diff) | |
download | Nim-c2bcfd8cd908265c358c60c4da137783b10a8549.tar.gz |
cheap fix for #10853 + better tuple subscript error message (#21767)
* cheap fix for #10853 * also better tuple subscript error message * weird
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/lowerings.nim | 2 | ||||
-rw-r--r-- | compiler/semexprs.nim | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/compiler/lowerings.nim b/compiler/lowerings.nim index bd81773a8..d70c713a1 100644 --- a/compiler/lowerings.nim +++ b/compiler/lowerings.nim @@ -132,7 +132,7 @@ proc lowerTupleUnpackingForAsgn*(g: ModuleGraph; n: PNode; idgen: IdGenerator; o var vpart = newNodeI(nkIdentDefs, tempAsNode.info, 3) vpart[0] = tempAsNode - vpart[1] = newNodeI(nkEmpty, value.info) + vpart[1] = newNodeI(nkTupleClassTy, value.info) vpart[2] = value v.add vpart result.add(v) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 930fd3516..a01466868 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1646,7 +1646,10 @@ proc semSubscript(c: PContext, n: PNode, flags: TExprFlags): PNode = {tyInt..tyInt64}: let idx = getOrdValue(n[1]) if idx >= 0 and idx < arr.len: n.typ = arr[toInt(idx)] - else: localError(c.config, n.info, "invalid index value for tuple subscript") + else: + localError(c.config, n.info, + "invalid index $1 in subscript for tuple of length $2" % + [$idx, $arr.len]) result = n else: result = nil |