Merge branch 'devel' into araq-compress3

This commit is contained in:
ringabout
2025-11-12 21:12:49 +08:00
committed by GitHub
14 changed files with 58 additions and 34 deletions

View File

@@ -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 }}

1
.gitignore vendored
View File

@@ -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

View File

@@ -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'

View File

@@ -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

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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:

View File

@@ -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):

View File

@@ -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

View File

@@ -1,3 +1,7 @@
discard """
disabled: "osx"
"""
proc testAsm() =
let src = 41
var dst = 0

View File

@@ -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

View File

@@ -3,6 +3,7 @@ discard """
disabled: "openbsd"
disabled: "freebsd"
disabled: "windows"
disabled: "osx"
"""
#[

View File

@@ -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) == "×××××"