summary refs log tree commit diff stats
path: root/compiler/lexer.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-04-24 13:08:42 +0200
committerAraq <rumpf_a@web.de>2015-04-24 13:08:42 +0200
commit6ca38472a13840906d6f113eb92c11a25db49224 (patch)
tree97bff3450e2a3ec5ccea4c089c3f463c26ce3de6 /compiler/lexer.nim
parenta5f321ea8f0cee7929afaba8bb88bde477c37937 (diff)
downloadNim-6ca38472a13840906d6f113eb92c11a25db49224.tar.gz
cleanups for underscores in tuple unpacking
Diffstat (limited to 'compiler/lexer.nim')
-rw-r--r--compiler/lexer.nim9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index 27cbfa9da..8080e0e8c 100644
--- a/compiler/lexer.nim
+++ b/compiler/lexer.nim
@@ -868,9 +868,14 @@ proc rawGetTok*(L: var TLexer, tok: var TToken) =
       tok.tokType = tkAccent
       inc(L.bufpos)
     of '_':
-      tok.tokType = tkSymbol
-      tok.ident = getIdent("_")
       inc(L.bufpos)
+      if L.buf[L.bufpos] notin SymChars:
+        tok.tokType = tkSymbol
+        tok.ident = getIdent("_")
+      else:
+        tok.literal = $c
+        tok.tokType = tkInvalid
+        lexMessage(L, errInvalidToken, c & " (\\" & $(ord(c)) & ')')
     of '\"':
       # check for extended raw string literal:
       var rawMode = L.bufpos > 0 and L.buf[L.bufpos-1] in SymChars