From 92468e99f7fb98d1965fc694553ddeb10522ae94 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Sat, 8 Nov 2025 13:04:05 +0800 Subject: [PATCH 1/5] fixes #25265; fixes #23453; Unable to build Nim 2.2.6 tools from source (#25269) fixes #25265; fixes #23453 `(addr deref (ptr object))` generated weak typedesc before, which causes problems for old GCC versions. As a bonus, by generating a typedesc for `deref (ptr object)`, it also fixes #23453 --- compiler/ccgexprs.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index d3e215ea56..8c8a12a327 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -919,6 +919,10 @@ proc genDeref(p: BProc, e: PNode, d: var TLoc) = return else: a = initLocExprSingleUse(p, e[0]) + + if e.typ != nil and e.typ.kind == tyObject: + # bug #23453 #25265 + discard getTypeDesc(p.module, e.typ) if d.k == locNone: # dest = *a; <-- We do not know that 'dest' is on the heap! # It is completely wrong to set 'd.storage' here, unless it's not yet From cc4c7377b296f59c8183b246cb51bd025aac48e4 Mon Sep 17 00:00:00 2001 From: Ryan McConnell Date: Mon, 10 Nov 2025 01:27:50 -0500 Subject: [PATCH 2/5] silence mass dump of `BareExcept` when using `unittest` (#25260) Seems better to change it to `CatchableError` instead? --- compiler/semstmts.nim | 5 +++-- lib/pure/unittest.nim | 9 --------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index ae4c744ead..479dcbfd28 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -394,8 +394,9 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags; expectedType: PType = nil) elif a.len == 1: # count number of ``except: body`` blocks inc catchAllExcepts - message(c.config, a.info, warnBareExcept, - "The bare except clause is deprecated; use `except CatchableError:` instead") + if noPanicOnExcept in c.graph.config.legacyFeatures: + message(c.config, a.info, warnBareExcept, + "The bare except clause is deprecated; use `except CatchableError:` instead") else: # support ``except KeyError, ValueError, ... : body`` if catchAllExcepts > 0: diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 38890b0d4f..f1e6138e45 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -547,14 +547,11 @@ template test*(name, body) {.dirty.} = for formatter in formatters: formatter.testStarted(name) - {.push warning[BareExcept]:off.} try: when declared(testSetupIMPLFlag): testSetupIMPL() when declared(testTeardownIMPLFlag): defer: testTeardownIMPL() - {.push warning[BareExcept]:on.} body - {.pop.} except Exception: let e = getCurrentException() @@ -577,7 +574,6 @@ template test*(name, body) {.dirty.} = ) testEnded(testResult) checkpoints = @[] - {.pop.} proc checkpoint*(msg: string) = ## Set a checkpoint identified by `msg`. Upon test failure all @@ -801,11 +797,8 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped = discard template expectBody(errorTypes, lineInfoLit, body): NimNode {.dirty.} = - {.push warning[BareExcept]:off.} try: - {.push warning[BareExcept]:on.} body - {.pop.} checkpoint(lineInfoLit & ": Expect Failed, no exception was thrown.") fail() except errorTypes: @@ -814,8 +807,6 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped = let err = getCurrentException() checkpoint(lineInfoLit & ": Expect Failed, " & $err.name & " was thrown.") fail() - {.pop.} - var errorTypes = newNimNode(nnkBracket) var hasException = false for exp in exceptions: From 2679b3221cc56f593ea4b08a2370591b0e2dad21 Mon Sep 17 00:00:00 2001 From: lit Date: Tue, 11 Nov 2025 19:01:07 +0800 Subject: [PATCH 3/5] fixes #19846; std/unicode.strip trailing big chars (#25274) fixes #19846 --- lib/pure/unicode.nim | 24 ++++++++++++++---------- tests/stdlib/tunicode.nim | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/lib/pure/unicode.nim b/lib/pure/unicode.nim index a953ce8ccd..6337c25a05 100644 --- a/lib/pure/unicode.nim +++ b/lib/pure/unicode.nim @@ -1037,6 +1037,19 @@ proc split*(s: openArray[char], sep: Rune, maxsplit: int = -1): seq[string] {.no ## that returns a sequence of substrings. accResult(split(s, sep, maxsplit)) +func getRuneHeadIdx(s: openArray[char], idx: int): int = + ## Given `[idx]` is within a Rune, then `s[result]` is the first byte of that Rune. + result = idx + if s[result] <= '\x7F': # 0b0111_1111 + return + # 0b1... + dec result + for _ in 0..1: + if s[result] >= '\xC0': # 0b11xx_xxxx + # 0b110... or 0b1110... + return + dec result + proc strip*(s: openArray[char], leading = true, trailing = true, runes: openArray[Rune] = unicodeSpaces): string {.noSideEffect, rtl, extern: "nucStrip".} = @@ -1073,18 +1086,9 @@ proc strip*(s: openArray[char], leading = true, trailing = true, xI: int rune: Rune while i >= 0: + i = getRuneHeadIdx(s, i) xI = i fastRuneAt(s, xI, rune) - var yI = i - 1 - while yI >= 0: - var - yIend = yI - pRune: Rune - fastRuneAt(s, yIend, pRune) - if yIend < xI: break - i = yI - rune = pRune - dec(yI) if not runes.contains(rune): eI = xI - 1 break diff --git a/tests/stdlib/tunicode.nim b/tests/stdlib/tunicode.nim index b9e68b15b4..a272d16c92 100644 --- a/tests/stdlib/tunicode.nim +++ b/tests/stdlib/tunicode.nim @@ -194,6 +194,23 @@ block stripTests: doAssert(strip("×text×", leading = false, runes = ["×".asRune]) == "×text") doAssert(strip("×text×", trailing = false, runes = ["×".asRune]) == "text×") + doAssert(strip("\u2000") == "") + doAssert(strip("a\u2000") == "a") + + # bug #19846 + block: + # check against unicode whose utf8 byteLen > 2 + doAssert(strip("‟„”“‛‚’‘‗•STR•‗‘’‚‛“”„‟", runes = "•‗‘’‚‛“”„‟".toRunes) == "STR") + let chi = "abc\u8377\u9020" + doAssert(strip(chi, leading = false, runes = ["\u9020".asRune]) == "abc\u8377") + doAssert(strip(chi) == chi) # the last byte of s is \x0a, which is in unicodeSpace + + let + grinning_face = "\u{1f600}" + thinking_face = "\u{1f914}" + doAssert(strip(grinning_face & thinking_face & thinking_face, + runes = thinking_face.toRunes) == grinning_face) + block repeatTests: doAssert repeat('c'.Rune, 5) == "ccccc" doAssert repeat("×".asRune, 5) == "×××××" From a57b6d8406a11c478e47dfd23b14058719c72cdb Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 11 Nov 2025 21:00:47 +0800 Subject: [PATCH 4/5] uses csources_v3 (#25273) --- .gitignore | 1 + config/build_config.txt | 6 +++--- nim.nimble | 2 +- readme.md | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index fad7909bd8..efb7dfe61e 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,7 @@ testament.db /csources /csources_v1 /csources_v2 +/csources_v3 /dist/ # /lib/fusion # fusion is now unbundled; `git status` should reveal if it's there so users can act on it diff --git a/config/build_config.txt b/config/build_config.txt index 66390e6958..feb3f0f7dc 100644 --- a/config/build_config.txt +++ b/config/build_config.txt @@ -1,5 +1,5 @@ nim_comment="key-value pairs for windows/posix bootstrapping build scripts" -nim_csourcesDir=csources_v2 -nim_csourcesUrl=https://github.com/nim-lang/csources_v2.git +nim_csourcesDir=csources_v3 +nim_csourcesUrl=https://github.com/nim-lang/csources_v3.git nim_csourcesBranch=master -nim_csourcesHash=86742fb02c6606ab01a532a0085784effb2e753e +nim_csourcesHash=eeab3ac46e93f10efda8e58c4db02b9438319d71 diff --git a/nim.nimble b/nim.nimble index bf195b0faf..d188d03451 100644 --- a/nim.nimble +++ b/nim.nimble @@ -6,7 +6,7 @@ license = "MIT" bin = @["compiler/nim", "nimsuggest/nimsuggest"] skipFiles = @["azure-pipelines.yml" , "build_all.bat" , "build_all.sh" , "build_nimble.bat" , "build_nimble.sh" , "changelog.md" , "koch.nim.cfg" , "nimblemeta.json" , "readme.md" , "security.md" ] -skipDirs = @["build" , "changelogs" , "ci" , "csources_v2" , "drnim" , "nimdoc", "testament"] +skipDirs = @["build" , "changelogs" , "ci" , "csources_v3" , "drnim" , "nimdoc", "testament"] before install: when defined(windows): diff --git a/readme.md b/readme.md index 69899da71b..8aeec5c8e4 100644 --- a/readme.md +++ b/readme.md @@ -49,7 +49,7 @@ Compiling the Nim compiler is quite straightforward if you follow these steps: First, the C source of an older version of the Nim compiler is needed to bootstrap the latest version because the Nim compiler itself is written in the Nim programming language. Those C sources are available within the -[``nim-lang/csources_v2``][csources-v2-repo] repository. +[``nim-lang/csources_v3``][csources-v3-repo] repository. Next, to build from source you will need: @@ -221,7 +221,7 @@ Copyright © 2006-2025 Andreas Rumpf, all rights reserved. [nimble-repo]: https://github.com/nim-lang/nimble [nimsuggest-repo]: https://github.com/nim-lang/nimsuggest [csources-repo-deprecated]: https://github.com/nim-lang/csources -[csources-v2-repo]: https://github.com/nim-lang/csources_v2 +[csources-v3-repo]: https://github.com/nim-lang/csources_v3 [badge-nim-irc]: https://img.shields.io/badge/chat-on_irc-blue.svg?style=flat-square [badge-nim-discord]: https://img.shields.io/discord/371759389889003530?color=blue&label=discord&logo=discord&logoColor=gold&style=flat-square [badge-nim-gitter]: https://img.shields.io/badge/chat-on_gitter-blue.svg?style=flat-square From d5549a3c65875b30888d3d68ca8145cd3ecbd3ed Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 12 Nov 2025 20:33:26 +0800 Subject: [PATCH 5/5] updates to macos-15 (#25278) ref https://github.com/actions/runner-images/issues/13046 --- .github/workflows/ci_docs.yml | 2 +- azure-pipelines.yml | 12 ++++++------ tests/compiler/tasm.nim | 4 ++++ tests/stdlib/tarithmetics.nim | 1 + tests/stdlib/thttpclient.nim | 1 + 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci_docs.yml b/.github/workflows/ci_docs.yml index da71181fd3..4cf7c7a837 100644 --- a/.github/workflows/ci_docs.yml +++ b/.github/workflows/ci_docs.yml @@ -45,7 +45,7 @@ jobs: - target: windows os: windows-latest - target: osx - os: macos-13 + os: macos-15 name: ${{ matrix.target }} runs-on: ${{ matrix.os }} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7fa0c3911d..96e747a730 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,12 +28,12 @@ jobs: # # g++-multilib : Depends: gcc-multilib (>= 4:5.3.1-1ubuntu1) but it is not going to be installed # vmImage: 'ubuntu-18.04' # CPU: i386 - OSX_amd64: - vmImage: 'macOS-13' - CPU: amd64 - OSX_amd64_cpp: - vmImage: 'macOS-13' - CPU: amd64 + OSX_arm64: + vmImage: 'macos-15' + CPU: arm64 + OSX_arm64_cpp: + vmImage: 'macos-15' + CPU: arm64 NIM_COMPILE_TO_CPP: true Windows_amd64_batch0_3: vmImage: 'windows-2025' diff --git a/tests/compiler/tasm.nim b/tests/compiler/tasm.nim index 63c8344f03..8a1f670c62 100644 --- a/tests/compiler/tasm.nim +++ b/tests/compiler/tasm.nim @@ -1,3 +1,7 @@ +discard """ + disabled: "osx" +""" + proc testAsm() = let src = 41 var dst = 0 diff --git a/tests/stdlib/tarithmetics.nim b/tests/stdlib/tarithmetics.nim index 0a6dd1fcfd..5b0cb93f3a 100644 --- a/tests/stdlib/tarithmetics.nim +++ b/tests/stdlib/tarithmetics.nim @@ -1,6 +1,7 @@ discard """ matrix: "--mm:refc; --mm:orc" targets: "c cpp js" + disabled: "osx" """ import std/assertions # TODO: in future work move existing arithmetic tests (tests/arithm/*) into this file diff --git a/tests/stdlib/thttpclient.nim b/tests/stdlib/thttpclient.nim index 99ccaba8b3..4f90bb8b06 100644 --- a/tests/stdlib/thttpclient.nim +++ b/tests/stdlib/thttpclient.nim @@ -3,6 +3,7 @@ discard """ disabled: "openbsd" disabled: "freebsd" disabled: "windows" + disabled: "osx" """ #[