mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 22:33:49 +00:00
'discard' can be used instead of 'nil' for empty case object branches
This commit is contained in:
@@ -1683,14 +1683,14 @@ proc parseObjectCase(p: var TParser): PNode =
|
||||
|
||||
proc parseObjectPart(p: var TParser): PNode =
|
||||
#| objectPart = IND{>} objectPart^+IND{=} DED
|
||||
#| / objectWhen / objectCase / 'nil' / declColonEquals
|
||||
#| / objectWhen / objectCase / 'nil' / 'discard' / declColonEquals
|
||||
if realInd(p):
|
||||
result = newNodeP(nkRecList, p)
|
||||
withInd(p):
|
||||
rawSkipComment(p, result)
|
||||
while sameInd(p):
|
||||
case p.tok.tokType
|
||||
of tkCase, tkWhen, tkSymbol, tkAccent, tkNil:
|
||||
of tkCase, tkWhen, tkSymbol, tkAccent, tkNil, tkDiscard:
|
||||
addSon(result, parseObjectPart(p))
|
||||
else:
|
||||
parMessage(p, errIdentifierExpected, p.tok)
|
||||
@@ -1704,7 +1704,7 @@ proc parseObjectPart(p: var TParser): PNode =
|
||||
of tkSymbol, tkAccent:
|
||||
result = parseIdentColonEquals(p, {withPragma})
|
||||
skipComment(p, result)
|
||||
of tkNil:
|
||||
of tkNil, tkDiscard:
|
||||
result = newNodeP(nkNilLit, p)
|
||||
getTok(p)
|
||||
else:
|
||||
|
||||
@@ -167,7 +167,7 @@ objectCase = 'case' identWithPragma ':' typeDesc ':'? COMMENT?
|
||||
(IND{>} objectBranches DED
|
||||
| IND{=} objectBranches)
|
||||
objectPart = IND{>} objectPart^+IND{=} DED
|
||||
/ objectWhen / objectCase / 'nil' / declColonEquals
|
||||
/ objectWhen / objectCase / 'nil' / 'discard' / declColonEquals
|
||||
object = 'object' pragma? ('of' typeDesc)? COMMENT? objectPart
|
||||
typeClassParam = ('var')? symbol
|
||||
typeClass = typeClassParam ^* ',' (pragma)? ('of' typeDesc ^* ',')?
|
||||
|
||||
20
web/news.txt
20
web/news.txt
@@ -2,6 +2,26 @@
|
||||
News
|
||||
====
|
||||
|
||||
..
|
||||
2015-03-01 Version 1.0.0 released
|
||||
=================================
|
||||
|
||||
|
||||
Changes affecting backwards compatibility
|
||||
-----------------------------------------
|
||||
|
||||
- Parameter names are finally properly ``gensym``'ed. This can break
|
||||
templates though that used to rely on the fact that they are not. However
|
||||
we found none such beast in the wild. (Bug #1915.)
|
||||
|
||||
|
||||
Language Additions
|
||||
------------------
|
||||
|
||||
- For empty ``case object`` branches ``discard`` can finally be used instead
|
||||
of ``nil``.
|
||||
|
||||
|
||||
2014-12-29 Version 0.10.2 released
|
||||
==================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user