From 255b3bb92e08402ce5e8f77bc2f0cb67c06e7b19 Mon Sep 17 00:00:00 2001 From: flywind Date: Mon, 17 Jan 2022 16:07:08 +0800 Subject: [PATCH 01/24] boot compiler with orc in tests --- koch.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koch.nim b/koch.nim index 295b1584b8b6..2a00c8e70bd7 100644 --- a/koch.nim +++ b/koch.nim @@ -548,7 +548,7 @@ proc runCI(cmd: string) = # boot without -d:nimHasLibFFI to make sure this still works # `--lib:lib` is needed for bootstrap on openbsd, for reasons described in # https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd). - kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --lib:lib") + kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --mm:orc --lib:lib") when false: # debugging: when you need to run only 1 test in CI, use something like this: execFold("debugging test", "nim r tests/stdlib/tosproc.nim") From ecb38a04bb76c55f55ffdd9bd8cfb62301c78b35 Mon Sep 17 00:00:00 2001 From: flywind Date: Mon, 17 Jan 2022 16:13:06 +0800 Subject: [PATCH 02/24] then boot orc --- koch.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/koch.nim b/koch.nim index 2a00c8e70bd7..cfb20c8e5cf6 100644 --- a/koch.nim +++ b/koch.nim @@ -548,7 +548,8 @@ proc runCI(cmd: string) = # boot without -d:nimHasLibFFI to make sure this still works # `--lib:lib` is needed for bootstrap on openbsd, for reasons described in # https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd). - kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --mm:orc --lib:lib") + kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --lib:lib") + kochExecFold("Boot Nim ORC", "boot -d:release --mm:orc -d:nimStrictMode --lib:lib") when false: # debugging: when you need to run only 1 test in CI, use something like this: execFold("debugging test", "nim r tests/stdlib/tosproc.nim") @@ -602,9 +603,6 @@ proc runCI(cmd: string) = execFold("Run atlas tests", "nim c -r -d:atlasTests tools/atlas/atlas.nim clone https://github.com/disruptek/balls") - when not defined(bsd): - # the BSDs are overwhelmed already, so only run this test on the other machines: - kochExecFold("Boot Nim ORC", "boot -d:release --mm:orc --lib:lib") proc testUnixInstall(cmdLineRest: string) = csource("-d:danger" & cmdLineRest) From 49bb5d9ac638334ed7f66d9b86fdff6b2d702d7a Mon Sep 17 00:00:00 2001 From: flywind Date: Tue, 18 Jan 2022 13:41:11 +0800 Subject: [PATCH 03/24] better types --- compiler/vm.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/vm.nim b/compiler/vm.nim index 3343eb781e0f..a066df2aedf3 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1387,8 +1387,9 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = regs[ra].node = newNodeI(nkBracket, c.debug[pc]) regs[ra].node.typ = typ newSeq(regs[ra].node.sons, count) + let nullValue = getNullValue(regs[ra].node.typ[0], c.debug[pc], c.config) for i in 0.. Date: Tue, 18 Jan 2022 14:02:18 +0800 Subject: [PATCH 04/24] Revert "better types" This reverts commit 49bb5d9ac638334ed7f66d9b86fdff6b2d702d7a. --- compiler/vm.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/vm.nim b/compiler/vm.nim index a066df2aedf3..3343eb781e0f 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1387,9 +1387,8 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg = regs[ra].node = newNodeI(nkBracket, c.debug[pc]) regs[ra].node.typ = typ newSeq(regs[ra].node.sons, count) - let nullValue = getNullValue(regs[ra].node.typ[0], c.debug[pc], c.config) for i in 0.. Date: Tue, 18 Jan 2022 14:34:18 +0800 Subject: [PATCH 05/24] use useMalloc --- koch.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koch.nim b/koch.nim index cfb20c8e5cf6..7a1b722922b8 100644 --- a/koch.nim +++ b/koch.nim @@ -549,7 +549,7 @@ proc runCI(cmd: string) = # `--lib:lib` is needed for bootstrap on openbsd, for reasons described in # https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd). kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --lib:lib") - kochExecFold("Boot Nim ORC", "boot -d:release --mm:orc -d:nimStrictMode --lib:lib") + kochExecFold("Boot Nim ORC", "boot -d:release --mm:orc -d:useMalloc -d:nimStrictMode --lib:lib") when false: # debugging: when you need to run only 1 test in CI, use something like this: execFold("debugging test", "nim r tests/stdlib/tosproc.nim") From 247302f98f2965a940b25c79e04f40c1bf1761ea Mon Sep 17 00:00:00 2001 From: flywind Date: Tue, 18 Jan 2022 15:17:54 +0800 Subject: [PATCH 06/24] try arc --- koch.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koch.nim b/koch.nim index 7a1b722922b8..bc73a2e1bfba 100644 --- a/koch.nim +++ b/koch.nim @@ -549,7 +549,7 @@ proc runCI(cmd: string) = # `--lib:lib` is needed for bootstrap on openbsd, for reasons described in # https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd). kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --lib:lib") - kochExecFold("Boot Nim ORC", "boot -d:release --mm:orc -d:useMalloc -d:nimStrictMode --lib:lib") + kochExecFold("Boot Nim ORC", "boot -d:release --mm:arc -d:useMalloc -d:nimStrictMode --lib:lib") when false: # debugging: when you need to run only 1 test in CI, use something like this: execFold("debugging test", "nim r tests/stdlib/tosproc.nim") From 9b532467088885358208f8ed7f49be388571fca2 Mon Sep 17 00:00:00 2001 From: flywind Date: Tue, 18 Jan 2022 15:38:44 +0800 Subject: [PATCH 07/24] Update koch.nim --- koch.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koch.nim b/koch.nim index bc73a2e1bfba..cfb20c8e5cf6 100644 --- a/koch.nim +++ b/koch.nim @@ -549,7 +549,7 @@ proc runCI(cmd: string) = # `--lib:lib` is needed for bootstrap on openbsd, for reasons described in # https://github.com/nim-lang/Nim/pull/14291 (`getAppFilename` bugsfor older nim on openbsd). kochExecFold("Boot in release mode", "boot -d:release -d:nimStrictMode --lib:lib") - kochExecFold("Boot Nim ORC", "boot -d:release --mm:arc -d:useMalloc -d:nimStrictMode --lib:lib") + kochExecFold("Boot Nim ORC", "boot -d:release --mm:orc -d:nimStrictMode --lib:lib") when false: # debugging: when you need to run only 1 test in CI, use something like this: execFold("debugging test", "nim r tests/stdlib/tosproc.nim") From 4067f88a31f40b47b878be513fbafdf6ff8dee1a Mon Sep 17 00:00:00 2001 From: xflywind Date: Tue, 22 Feb 2022 11:08:22 +0800 Subject: [PATCH 08/24] fix bug one --- lib/pure/unittest.nim | 44 +++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index b1c01f8db7d7..09105164626a 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -751,22 +751,38 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped = expect IOError, OSError, ValueError, AssertionDefect: defectiveRobot() - template expectBody(errorTypes, lineInfoLit, body): NimNode {.dirty.} = - try: - body - checkpoint(lineInfoLit & ": Expect Failed, no exception was thrown.") - fail() - except errorTypes: - discard - except: - checkpoint(lineInfoLit & ": Expect Failed, unexpected exception was thrown.") - fail() - - var errorTypes = newNimNode(nnkBracket) + result = newNimNode(nnkStmtList) + let lineInfoLit = exceptions[0].lineInfo + let tryExpr = newNimNode(nnkTryStmt) + tryExpr.add quote do: + `body` + checkpoint(`lineInfoLit` & ": Expect Failed, no exception was thrown.") + fail() + + var exceptExceptionBranch = newNimNode(nnkExceptBranch) for exp in exceptions: - errorTypes.add(exp) + exceptExceptionBranch.add(exp) + + + # StmtList + # DiscardStmt + # Empty + + var stmtList = newNimNode(nnkStmtList) + var discardStmt = newNimNode(nnkDiscardStmt) + discardStmt.add newNimNode(nnkEmpty) + stmtList.add discardStmt + exceptExceptionBranch.add stmtList + + var exceptBranch = newNimNode(nnkExceptBranch) + exceptBranch.add quote do: + checkpoint(`lineInfoLit` & ": Expect Failed, unexpected exception was thrown.") + fail() + + tryExpr.add exceptExceptionBranch + tryExpr.add exceptBranch + result.add tryExpr - result = getAst(expectBody(errorTypes, errorTypes.lineInfo, body)) proc disableParamFiltering* = ## disables filtering tests with the command line params From 7eb8a6f4011f542577de627631c2a836decfc1b9 Mon Sep 17 00:00:00 2001 From: xflywind Date: Tue, 22 Feb 2022 23:29:47 +0800 Subject: [PATCH 09/24] work around --- tests/exception/texcas.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/exception/texcas.nim b/tests/exception/texcas.nim index ad6819f111b5..edaf80aeba61 100644 --- a/tests/exception/texcas.nim +++ b/tests/exception/texcas.nim @@ -38,6 +38,6 @@ testTryAsExpr(5) doAssert(not compiles( try: echo 1 - except [KeyError as ex1, ValueError as ex2]: + except KeyError as ex1, ValueError as ex2: echo 2 )) From cec2b8533702147b0928ea753f140f9c47dc732b Mon Sep 17 00:00:00 2001 From: xflywind Date: Thu, 24 Feb 2022 17:03:30 +0800 Subject: [PATCH 10/24] investigate why the stacktrace is lost --- compiler/ropes.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ropes.nim b/compiler/ropes.nim index 1e795733775f..02a94bab4de7 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -66,7 +66,7 @@ type # copy the format strings # though it is not necessary) Rope* = ref RopeObj - RopeObj*{.acyclic.} = object of RootObj # the empty rope is represented + RopeObj*{.acyclic.} = object # the empty rope is represented # by nil to safe space left, right: Rope L: int # <= 0 if a leaf From 21feba6154b5216f2db5356ef7613c1117716c41 Mon Sep 17 00:00:00 2001 From: xflywind Date: Thu, 24 Feb 2022 18:41:37 +0800 Subject: [PATCH 11/24] another try --- compiler/ropes.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ropes.nim b/compiler/ropes.nim index 02a94bab4de7..088a46a0deca 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -66,7 +66,7 @@ type # copy the format strings # though it is not necessary) Rope* = ref RopeObj - RopeObj*{.acyclic.} = object # the empty rope is represented + RopeObj* = object # the empty rope is represented # by nil to safe space left, right: Rope L: int # <= 0 if a leaf From 66507d5f346de4adabcc56a3543b3077a56d627f Mon Sep 17 00:00:00 2001 From: xflywind Date: Thu, 24 Feb 2022 19:44:57 +0800 Subject: [PATCH 12/24] add nodestroy --- compiler/ccgexprs.nim | 2 +- compiler/ropes.nim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 1f103511514b..25955c66c367 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -3127,7 +3127,7 @@ proc genConstTuple(p: BProc, n: PNode; isConst: bool; tup: PType): Rope = else: result.add genBracedInit(p, it, isConst, tup[i]) result.add("}\n") -proc genConstSeq(p: BProc, n: PNode, t: PType; isConst: bool): Rope = +proc genConstSeq(p: BProc, n: PNode, t: PType; isConst: bool): Rope {.nodestroy.} = var data = "{{$1, $1 | NIM_STRLIT_FLAG}" % [n.len.rope] let base = t.skipTypes(abstractInst)[0] if n.len > 0: diff --git a/compiler/ropes.nim b/compiler/ropes.nim index 088a46a0deca..1e795733775f 100644 --- a/compiler/ropes.nim +++ b/compiler/ropes.nim @@ -66,7 +66,7 @@ type # copy the format strings # though it is not necessary) Rope* = ref RopeObj - RopeObj* = object # the empty rope is represented + RopeObj*{.acyclic.} = object of RootObj # the empty rope is represented # by nil to safe space left, right: Rope L: int # <= 0 if a leaf From 7139b242a5481d50cc0760d90e9d4fb067640f81 Mon Sep 17 00:00:00 2001 From: xflywind Date: Thu, 24 Feb 2022 23:43:25 +0800 Subject: [PATCH 13/24] change rope to string --- compiler/ccgexprs.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 25955c66c367..12a30c603ce7 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -3127,15 +3127,15 @@ proc genConstTuple(p: BProc, n: PNode; isConst: bool; tup: PType): Rope = else: result.add genBracedInit(p, it, isConst, tup[i]) result.add("}\n") -proc genConstSeq(p: BProc, n: PNode, t: PType; isConst: bool): Rope {.nodestroy.} = - var data = "{{$1, $1 | NIM_STRLIT_FLAG}" % [n.len.rope] +proc genConstSeq(p: BProc, n: PNode, t: PType; isConst: bool): Rope = + var data = strutils.`%`("{{$1, $1 | NIM_STRLIT_FLAG}", [$n.len]) let base = t.skipTypes(abstractInst)[0] if n.len > 0: # array part needs extra curlies: data.add(", {") for i in 0.. 0: data.addf(",$n", []) - data.add genBracedInit(p, n[i], isConst, base) + if i > 0: data.add(",\n") + data.add $genBracedInit(p, n[i], isConst, base) data.add("}") data.add("}") From 01792920a47eb1d98e78bcc0447c610be7bf98b1 Mon Sep 17 00:00:00 2001 From: xflywind Date: Fri, 25 Feb 2022 10:15:41 +0800 Subject: [PATCH 14/24] clean up --- lib/pure/unittest.nim | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 09105164626a..96baf0eb1d2c 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -763,11 +763,6 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped = for exp in exceptions: exceptExceptionBranch.add(exp) - - # StmtList - # DiscardStmt - # Empty - var stmtList = newNimNode(nnkStmtList) var discardStmt = newNimNode(nnkDiscardStmt) discardStmt.add newNimNode(nnkEmpty) From 690e58663b505e2c71f88cafea19e0904f357087 Mon Sep 17 00:00:00 2001 From: xflywind Date: Fri, 25 Feb 2022 10:19:30 +0800 Subject: [PATCH 15/24] split tests --- tests/exception/t7115.nim | 11 +++++++++++ tests/exception/texcas.nim | 8 -------- 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 tests/exception/t7115.nim diff --git a/tests/exception/t7115.nim b/tests/exception/t7115.nim new file mode 100644 index 000000000000..6661850eaa79 --- /dev/null +++ b/tests/exception/t7115.nim @@ -0,0 +1,11 @@ +discard """ + targets: "c cpp" +""" + +# bug #7115 +doAssert(not compiles( + try: + echo 1 + except [KeyError as ex1, ValueError as ex2]: + echo 2 +)) diff --git a/tests/exception/texcas.nim b/tests/exception/texcas.nim index edaf80aeba61..9cf248f9b891 100644 --- a/tests/exception/texcas.nim +++ b/tests/exception/texcas.nim @@ -33,11 +33,3 @@ proc testTryAsExpr(i: int) = test[Exception]() test2() testTryAsExpr(5) - -# see bug #7115 -doAssert(not compiles( - try: - echo 1 - except KeyError as ex1, ValueError as ex2: - echo 2 -)) From 2fa71301e360d97724953e80fed8708946ba1743 Mon Sep 17 00:00:00 2001 From: xflywind Date: Fri, 25 Feb 2022 10:59:05 +0800 Subject: [PATCH 16/24] merge --- tests/exception/t7115.nim | 11 ----------- tests/exception/texcas.nim | 9 +++++++++ 2 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 tests/exception/t7115.nim diff --git a/tests/exception/t7115.nim b/tests/exception/t7115.nim deleted file mode 100644 index 6661850eaa79..000000000000 --- a/tests/exception/t7115.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - targets: "c cpp" -""" - -# bug #7115 -doAssert(not compiles( - try: - echo 1 - except [KeyError as ex1, ValueError as ex2]: - echo 2 -)) diff --git a/tests/exception/texcas.nim b/tests/exception/texcas.nim index 9cf248f9b891..15bba08f8c44 100644 --- a/tests/exception/texcas.nim +++ b/tests/exception/texcas.nim @@ -33,3 +33,12 @@ proc testTryAsExpr(i: int) = test[Exception]() test2() testTryAsExpr(5) + +# see bug #7115 +when not defined(cpp): + doAssert(not compiles( + try: + echo 1 + except [KeyError as ex1, ValueError as ex2]: + echo 2 + )) From 455a99a10363831f56cd8bd0c5c6cdfbe8fc0bed Mon Sep 17 00:00:00 2001 From: flywind Date: Fri, 25 Feb 2022 11:42:48 +0800 Subject: [PATCH 17/24] Update tests/exception/texcas.nim --- tests/exception/texcas.nim | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/exception/texcas.nim b/tests/exception/texcas.nim index 15bba08f8c44..edaf80aeba61 100644 --- a/tests/exception/texcas.nim +++ b/tests/exception/texcas.nim @@ -35,10 +35,9 @@ test2() testTryAsExpr(5) # see bug #7115 -when not defined(cpp): - doAssert(not compiles( - try: - echo 1 - except [KeyError as ex1, ValueError as ex2]: - echo 2 - )) +doAssert(not compiles( + try: + echo 1 + except KeyError as ex1, ValueError as ex2: + echo 2 +)) From 5683f129beb6f7f6cf309474083b07798288f5df Mon Sep 17 00:00:00 2001 From: xflywind Date: Sun, 6 Mar 2022 10:16:13 +0800 Subject: [PATCH 18/24] Revert "fix bug one" This reverts commit 4067f88a31f40b47b878be513fbafdf6ff8dee1a. --- lib/pure/unittest.nim | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 96baf0eb1d2c..b1c01f8db7d7 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -751,33 +751,22 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped = expect IOError, OSError, ValueError, AssertionDefect: defectiveRobot() - result = newNimNode(nnkStmtList) - let lineInfoLit = exceptions[0].lineInfo - let tryExpr = newNimNode(nnkTryStmt) - tryExpr.add quote do: - `body` - checkpoint(`lineInfoLit` & ": Expect Failed, no exception was thrown.") - fail() - - var exceptExceptionBranch = newNimNode(nnkExceptBranch) - for exp in exceptions: - exceptExceptionBranch.add(exp) - - var stmtList = newNimNode(nnkStmtList) - var discardStmt = newNimNode(nnkDiscardStmt) - discardStmt.add newNimNode(nnkEmpty) - stmtList.add discardStmt - exceptExceptionBranch.add stmtList - - var exceptBranch = newNimNode(nnkExceptBranch) - exceptBranch.add quote do: - checkpoint(`lineInfoLit` & ": Expect Failed, unexpected exception was thrown.") - fail() + template expectBody(errorTypes, lineInfoLit, body): NimNode {.dirty.} = + try: + body + checkpoint(lineInfoLit & ": Expect Failed, no exception was thrown.") + fail() + except errorTypes: + discard + except: + checkpoint(lineInfoLit & ": Expect Failed, unexpected exception was thrown.") + fail() - tryExpr.add exceptExceptionBranch - tryExpr.add exceptBranch - result.add tryExpr + var errorTypes = newNimNode(nnkBracket) + for exp in exceptions: + errorTypes.add(exp) + result = getAst(expectBody(errorTypes, errorTypes.lineInfo, body)) proc disableParamFiltering* = ## disables filtering tests with the command line params From 1b7e23c1e72fec8feff739ce1353f7746092e051 Mon Sep 17 00:00:00 2001 From: xflywind Date: Sun, 6 Mar 2022 10:17:10 +0800 Subject: [PATCH 19/24] redo --- compiler/semstmts.nim | 7 ++++++- tests/exception/texcas.nim | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c2b385c80d58..650c13c4ece1 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -215,7 +215,12 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = if a.len == 2 and a[0].kind == nkBracket: # rewrite ``except [a, b, c]: body`` -> ```except a, b, c: body``` - a.sons[0..0] = a[0].sons + var tmp1 = a[0].sons + var tmp2 = a[1] + a.sons.setLen(tmp1.len+1) + for i in 0.. Date: Sun, 6 Mar 2022 10:36:29 +0800 Subject: [PATCH 20/24] except --- compiler/semstmts.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 650c13c4ece1..a088c3334b07 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -215,12 +215,12 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = if a.len == 2 and a[0].kind == nkBracket: # rewrite ``except [a, b, c]: body`` -> ```except a, b, c: body``` - var tmp1 = a[0].sons - var tmp2 = a[1] - a.sons.setLen(tmp1.len+1) - for i in 0.. Date: Sun, 6 Mar 2022 20:22:16 +0800 Subject: [PATCH 21/24] compact --- compiler/semstmts.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index a088c3334b07..a6aede7b8088 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -216,11 +216,10 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = if a.len == 2 and a[0].kind == nkBracket: # rewrite ``except [a, b, c]: body`` -> ```except a, b, c: body``` let exceptionBracket = a[0] - let exceptBody = a[1] a.sons.setLen(exceptionBracket.len+1) + a[^1] = move(a[1]) for i in 0.. Date: Sun, 6 Mar 2022 20:55:03 +0800 Subject: [PATCH 22/24] another way to go --- compiler/semstmts.nim | 6 +----- lib/system.nim | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index a6aede7b8088..c2b385c80d58 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -215,11 +215,7 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = if a.len == 2 and a[0].kind == nkBracket: # rewrite ``except [a, b, c]: body`` -> ```except a, b, c: body``` - let exceptionBracket = a[0] - a.sons.setLen(exceptionBracket.len+1) - a[^1] = move(a[1]) - for i in 0.. 5; 6; 7; 8 a .. (when b is BackwardsIndex: succ(b) else: pred(b)) -template spliceImpl(s, a, L, b: untyped): untyped = +template spliceImpl(s, a, L, b: typed): untyped = # make room for additional elements or cut: var shift = b.len - max(0,L) # ignore negative slice size var newLen = s.len + shift From 4e7f15ddad3d0c96aa7dde217142b5325f3be3e6 Mon Sep 17 00:00:00 2001 From: xflywind Date: Sun, 6 Mar 2022 21:06:46 +0800 Subject: [PATCH 23/24] fix now --- compiler/semstmts.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index c2b385c80d58..a6aede7b8088 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -215,7 +215,11 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = if a.len == 2 and a[0].kind == nkBracket: # rewrite ``except [a, b, c]: body`` -> ```except a, b, c: body``` - a.sons[0..0] = a[0].sons + let exceptionBracket = a[0] + a.sons.setLen(exceptionBracket.len+1) + a[^1] = move(a[1]) + for i in 0.. Date: Tue, 27 Sep 2022 01:13:00 +0800 Subject: [PATCH 24/24] revert rope changes --- compiler/ccgexprs.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index f6592027723d..4c15101a9828 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -3155,14 +3155,14 @@ proc genConstTuple(p: BProc, n: PNode; isConst: bool; tup: PType): Rope = result.add("}\n") proc genConstSeq(p: BProc, n: PNode, t: PType; isConst: bool): Rope = - var data = strutils.`%`("{{$1, $1 | NIM_STRLIT_FLAG}", [$n.len]) + var data = "{{$1, $1 | NIM_STRLIT_FLAG}" % [n.len.rope] let base = t.skipTypes(abstractInst)[0] if n.len > 0: # array part needs extra curlies: data.add(", {") for i in 0.. 0: data.add(",\n") - data.add $genBracedInit(p, n[i], isConst, base) + if i > 0: data.addf(",$n", []) + data.add genBracedInit(p, n[i], isConst, base) data.add("}") data.add("}")