diff options
-rw-r--r-- | compiler/parser.nim | 14 | ||||
-rw-r--r-- | web/news/version_0_15_released.rst | 13 |
2 files changed, 23 insertions, 4 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 6132216e1..8b20b56db 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -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: diff --git a/web/news/version_0_15_released.rst b/web/news/version_0_15_released.rst index 0dfde1ce2..80f178093 100644 --- a/web/news/version_0_15_released.rst +++ b/web/news/version_0_15_released.rst @@ -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 ----------------- |