fixes regressions
This commit is contained in:
parent
f6def4286c
commit
331d1a6ca1
2 changed files with 21 additions and 10 deletions
13
changelog.md
13
changelog.md
|
|
@ -23,6 +23,19 @@
|
||||||
|
|
||||||
#### Breaking changes in the compiler
|
#### Breaking changes in the compiler
|
||||||
|
|
||||||
|
- The compiler now implements the "generic symbol prepass" for `when` statements
|
||||||
|
in generics, see bug #8603. This means that code like this does not compile
|
||||||
|
anymore:
|
||||||
|
|
||||||
|
```nim
|
||||||
|
proc enumToString*(enums: openArray[enum]): string =
|
||||||
|
# typo: 'e' instead 'enums'
|
||||||
|
when e.low.ord >= 0 and e.high.ord < 256:
|
||||||
|
result = newString(enums.len)
|
||||||
|
else:
|
||||||
|
result = newString(enums.len * 2)
|
||||||
|
```
|
||||||
|
|
||||||
### Library additions
|
### Library additions
|
||||||
|
|
||||||
- There is a new stdlib module `editdistance` as a replacement for the
|
- There is a new stdlib module `editdistance` as a replacement for the
|
||||||
|
|
|
||||||
|
|
@ -706,28 +706,26 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode =
|
||||||
elif templToExpand(s):
|
elif templToExpand(s):
|
||||||
return semPatternBody(c, semTemplateExpr(c.c, n, s, {efNoSemCheck}))
|
return semPatternBody(c, semTemplateExpr(c.c, n, s, {efNoSemCheck}))
|
||||||
|
|
||||||
if n.kind == nkInfix and n.sons[0].kind == nkIdent:
|
if n.kind == nkInfix and (let id = considerQuotedIdent(c.c, n[0]); id != nil):
|
||||||
# we interpret `*` and `|` only as pattern operators if they occur in
|
# we interpret `*` and `|` only as pattern operators if they occur in
|
||||||
# infix notation, so that '`*`(a, b)' can be used for verbatim matching:
|
# infix notation, so that '`*`(a, b)' can be used for verbatim matching:
|
||||||
let opr = n.sons[0]
|
if id.s == "*" or id.s == "**":
|
||||||
if opr.ident.s == "*" or opr.ident.s == "**":
|
|
||||||
result = newNodeI(nkPattern, n.info, n.len)
|
result = newNodeI(nkPattern, n.info, n.len)
|
||||||
result.sons[0] = opr
|
result.sons[0] = newIdentNode(id, n.info)
|
||||||
result.sons[1] = semPatternBody(c, n.sons[1])
|
result.sons[1] = semPatternBody(c, n.sons[1])
|
||||||
result.sons[2] = expectParam(c, n.sons[2])
|
result.sons[2] = expectParam(c, n.sons[2])
|
||||||
return
|
return
|
||||||
elif opr.ident.s == "|":
|
elif id.s == "|":
|
||||||
result = newNodeI(nkPattern, n.info, n.len)
|
result = newNodeI(nkPattern, n.info, n.len)
|
||||||
result.sons[0] = opr
|
result.sons[0] = newIdentNode(id, n.info)
|
||||||
result.sons[1] = semPatternBody(c, n.sons[1])
|
result.sons[1] = semPatternBody(c, n.sons[1])
|
||||||
result.sons[2] = semPatternBody(c, n.sons[2])
|
result.sons[2] = semPatternBody(c, n.sons[2])
|
||||||
return
|
return
|
||||||
|
|
||||||
if n.kind == nkPrefix and n.sons[0].kind == nkIdent:
|
if n.kind == nkPrefix and (let id = considerQuotedIdent(c.c, n[0]); id != nil):
|
||||||
let opr = n.sons[0]
|
if id.s == "~":
|
||||||
if opr.ident.s == "~":
|
|
||||||
result = newNodeI(nkPattern, n.info, n.len)
|
result = newNodeI(nkPattern, n.info, n.len)
|
||||||
result.sons[0] = opr
|
result.sons[0] = newIdentNode(id, n.info)
|
||||||
result.sons[1] = semPatternBody(c, n.sons[1])
|
result.sons[1] = semPatternBody(c, n.sons[1])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue