mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-10 13:48:10 +00:00
prepare for #3898
This commit is contained in:
@@ -686,11 +686,19 @@ proc primarySuffix(p: var TParser, r: PNode, baseIndent: int): PNode =
|
||||
#| | '{' optInd indexExprList optPar '}'
|
||||
#| | &( '`'|IDENT|literal|'cast'|'addr'|'type') expr # command syntax
|
||||
result = r
|
||||
|
||||
template somePar() =
|
||||
if p.tok.strongSpaceA > 0:
|
||||
if p.strongSpaces:
|
||||
break
|
||||
else:
|
||||
parMessage(p, warnDeprecated,
|
||||
"a [b] will be parsed as command syntax; spacing")
|
||||
while p.tok.indent < 0 or
|
||||
(p.tok.tokType == tkDot and p.tok.indent >= baseIndent):
|
||||
case p.tok.tokType
|
||||
of tkParLe:
|
||||
if p.strongSpaces and p.tok.strongSpaceA > 0: break
|
||||
somePar()
|
||||
result = namedParams(p, result, nkCall, tkParRi)
|
||||
if result.len > 1 and result.sons[1].kind == nkExprColonExpr:
|
||||
result.kind = nkObjConstr
|
||||
@@ -705,10 +713,10 @@ proc primarySuffix(p: var TParser, r: PNode, baseIndent: int): PNode =
|
||||
result = dotExpr(p, result)
|
||||
result = parseGStrLit(p, result)
|
||||
of tkBracketLe:
|
||||
if p.strongSpaces and p.tok.strongSpaceA > 0: break
|
||||
somePar()
|
||||
result = namedParams(p, result, nkBracketExpr, tkBracketRi)
|
||||
of tkCurlyLe:
|
||||
if p.strongSpaces and p.tok.strongSpaceA > 0: break
|
||||
somePar()
|
||||
result = namedParams(p, result, nkCurlyExpr, tkCurlyRi)
|
||||
of tkSymbol, tkAccent, tkIntLit..tkCharLit, tkNil, tkCast, tkAddr, tkType:
|
||||
if p.inPragma == 0:
|
||||
|
||||
@@ -17,7 +17,18 @@ Changes affecting backwards compatibility
|
||||
no longer strips and splits characters out of the target string
|
||||
by the entire set of characters. Instead, it now behaves in a
|
||||
similar fashion to ``split`` with ``string`` and ``char``
|
||||
delimiters.
|
||||
delimiters. Use ``splitWhitespace`` to get the old behaviour.
|
||||
- The command invocation syntax will soon apply to open brackets
|
||||
and curlies too. This means that code like ``a [i]`` will be
|
||||
interpreted as ``a([i])`` and not as ``a[i]`` anymore. Likewise
|
||||
``f (a, b)`` means that the tuple ``(a, b)`` is passed to ``f``.
|
||||
The compiler produces a warning for ``a [i]``::
|
||||
|
||||
Warning: a [b] will be parsed as command syntax; spacing is deprecated
|
||||
|
||||
See `https://github.com/nim-lang/Nim/issues/3898`_ for the relevant
|
||||
discussion.
|
||||
|
||||
|
||||
Library Additions
|
||||
-----------------
|
||||
|
||||
Reference in New Issue
Block a user