Skip to content

Commit b4a67ff

Browse files
AraqPMunch
authored andcommitted
fixes nim-lang#19015 [backport:1.6] (nim-lang#19204)
1 parent 7bbe0b4 commit b4a67ff

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
or define your own `Math.trunc` polyfill using the [`emit` pragma](https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma). Nim uses
1212
`Math.trunc` for the division and modulo operators for integers.
1313

14+
- Optional parameters in combination with `: body` syntax (RFC #405) are now opt-in via
15+
`experimental:flexibleOptionalParams`.
16+
1417
## Standard library additions and changes
1518

1619
- `macros.parseExpr` and `macros.parseStmt` now accept an optional

compiler/options.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ type
207207
strictNotNil,
208208
overloadableEnums,
209209
strictEffects,
210-
unicodeOperators
210+
unicodeOperators,
211+
flexibleOptionalParams
211212

212213
LegacyFeature* = enum
213214
allowSemcheckedAstModification,

compiler/sigmatch.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2461,7 +2461,8 @@ proc matchesAux(c: PContext, n, nOrig: PNode, m: var TCandidate, marker: var Int
24612461
if m.callee.n[f].kind != nkSym:
24622462
internalError(c.config, n[a].info, "matches")
24632463
noMatch()
2464-
if a >= firstArgBlock: f = max(f, m.callee.n.len - (n.len - a))
2464+
if flexibleOptionalParams in c.features and a >= firstArgBlock:
2465+
f = max(f, m.callee.n.len - (n.len - a))
24652466
formal = m.callee.n[f].sym
24662467
m.firstMismatch.kind = kTypeMismatch
24672468
if containsOrIncl(marker, formal.position) and container.isNil:

tests/misc/trfc405.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2+
{.experimental: "flexibleOptionalParams".}
3+
14
# https://github.com/nim-lang/RFCs/issues/405
25

36
template main =

0 commit comments

Comments
 (0)