From dd0b1469a8744dd020545ced6743631544c814c8 Mon Sep 17 00:00:00 2001 From: litlighilit Date: Sun, 25 May 2025 15:44:33 +0800 Subject: [PATCH 1/2] fixup `super()` without arg not compile --- src/pylib/pysugar/stmt/class.nim | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/pylib/pysugar/stmt/class.nim b/src/pylib/pysugar/stmt/class.nim index 3f7e3602f..75eed7e89 100644 --- a/src/pylib/pysugar/stmt/class.nim +++ b/src/pylib/pysugar/stmt/class.nim @@ -26,28 +26,30 @@ proc replaceSuperCall(n: var NimNode, defSupCls: NimNode, methKind: MethKind): b nret callSup.kind == nnkCall nret callSup[0].eqIdent "super" - var cLen = callSup.len + var cArgLen = callSup.len - 1 let supCls = - if cLen > 2: - if cLen > 3: error "super([[, self]]) expected, but got too many args" + if cArgLen > 1: + if cArgLen > 2: error "super([[, self]]) expected, but got too many args" callSup[1] else: - if cLen == 1: + if cArgLen == 0: callSup.add defSupCls - cLen.inc + cArgLen.inc defSupCls - if methKind == mkCls: - if cLen == 3: - expectIdent callSup[2], "cls" + template expectLastOrAdd(id: string) = + if cArgLen == 2: + expectIdent callSup[2], id else: - callSup.add ident"cls" - cLen.inc + callSup.add ident id + cArgLen.inc + + if methKind == mkCls: + expectLastOrAdd "cls" n = newDotExpr(supCls, n[0][1]).newCall(callSup[2]) elif methKind == mkNorm: - if cLen > 1: - expectIdent callSup[2], "self" - n[0][0] = newCall(supCls, ident"self") + expectLastOrAdd "self" + n[0][0] = newCall(supCls, callSup[2]) #let meth = n[0][1] #let args = n[1..^1] From 0bbb29057030e652b0e6ccd6e0e00f733ae1a5f6 Mon Sep 17 00:00:00 2001 From: litlighilit Date: Sun, 25 May 2025 15:17:18 +0800 Subject: [PATCH 2/2] bump-version: 0.9.11 with changelog [skip ci] as previous commit has been passed --- changelogs/changelog_0_9_11.md | 120 +++++++++++++++++++++++++++++++++ src/pylib/versionInfo.nim | 2 +- 2 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 changelogs/changelog_0_9_11.md diff --git a/changelogs/changelog_0_9_11.md b/changelogs/changelog_0_9_11.md new file mode 100644 index 000000000..9e2cf3744 --- /dev/null +++ b/changelogs/changelog_0_9_11.md @@ -0,0 +1,120 @@ + +# v0.9.11 - 2025-05-25 + +## Bug Fixes + +* py: + + * complex: + + * allow pow's 1arg being SomeNumber; add mixin `==`. (f6f5ba590) + * pow: more precise for SomeInteger. (5a456efc1) + + * class: + + * attribute expressions were not rewritten. (6fd516c77) + * top-level classes and methods now properly exported. (a8aeddd91) + * method order corrected for non-auto restype. (131ec42b0) + * `:=` now always declares a new variable. (7d1aed865) +* pysugar/class: + + * `super(typ, obj)` parameters were reversed. (67bf79812) +* sugar: + + * `raise a.b...` didn’t compile. (674943b93) +* bool: + + * caused deadloop for `a==b` when `==` not declared. (9278a5d2c) +* Lib: + + * inspect: getsourcelines did not compile. (e3cb4db47) +* doc: + + * Lib/time fetchDoc not working. (0359fac95) + +## Feature Additions + +### builtins + +* `dir(cls)`. (045c692aa) + +### Lib + +* os: + + * `cpu_count`. (66e693522) + * `sched_{get,set}affinity`, `process_cpu_count`. (8a87354f7) +* unittest: + + * `TestCase.run`. (f8f17f931) + * `main`. (8311af01e) +* typing: + + * `OptionalObj`. (f9d6470a5) + +### class/sugar + +* `cls.dunder.dict.keys` → `cls.__dict__.keys()`. (f48a3fa86) +* auto call `__init_subclass__`. (f65706587) +* support `cls.new` → `cls.__new__`. (3351c5810) +* support `cls(...)` as sugar for `newCls(...)`. (e4db1bab7) +* support chained comparisons (e.g., `1 < x < 3`). (c0b83a61f) +* support Python function calls inside class bodies. (d092211f6) +* support `v: typ` in `def`, where typ can be `Literal`/`Final` → `const`/`let`. (3f2b4d05e) + +### pyconfig + +* `AC_CHECK_HEADER_THEN_FUNCS`, `AC_CHECK_HEADER[S]`. (d1aec1a9c) + +### EXT + +* `newPyListOfStr`. (32740352a) +* `OptionalObj`. (f9d6470a5) + +## Breaking Changes + +* EXT: + + * unexport `io.raiseOsOrFileNotFoundError`. (d9c7dc16c) +* Lib: + + * use `OptionalObj` for `datetime.tzname`, `inspect.*`, `signal.strsignal`, `os.*_cpu_count`. (b4eecd5bb) + +## Improvements + +* sugar/class: + + * enhanced support for top-level export, method reordering, variable declarations, and expression rewriting. (a8aeddd91, 7d1aed865, 131ec42b0, 6fd516c77) +* doc: + + * updated readme to use `Xxx` instead of `newXxx` for class instantiation. (fb91f6b85) + +## Refactor + +* os\_impl: + + * reimplemented `posix_like/errnoUtils`; renamed `errnoHandle` to `errnoRaise`. (b75367d93) +* nimpatch: + + * integrated `nim-lang/Nim#23456` to `nimpatch/`. (337b34676) +* exprRewrite: + + * added `mparser` argument to `toPyExpr`. (e4db1bab7) + +## Chores + +* CI: + + * allow `workflow_dispatch` in docs. (56e3d0d43) +* Nimble: + + * require Nim > 2.0.4; added changelog subcommand; merged logic. (1986af327) + +## Workarounds + +* os.path.join: + + * support for 3+ arguments (ref d1ca7cd7777a3fb160743). (982f819fe) +* compiles macro: + + * now takes effect when modifying macrocache. (ddc447a22) diff --git a/src/pylib/versionInfo.nim b/src/pylib/versionInfo.nim index 038af9345..9d886723e 100644 --- a/src/pylib/versionInfo.nim +++ b/src/pylib/versionInfo.nim @@ -11,7 +11,7 @@ type const Major* = 0 Minor* = 9 - Patch* = 10 + Patch* = 11 ReleaseLevel* = "alpha" Serial* = 0