summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ast.nim2
-rw-r--r--compiler/lexer.nim4
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 48e8afa67..62a3492cc 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1660,6 +1660,8 @@ proc getInt64*(a: PNode): int64 {.deprecated: "use getInt".} =
 proc getFloat*(a: PNode): BiggestFloat =
   case a.kind
   of nkFloatLiterals: result = a.floatVal
+  of nkCharLit, nkUIntLit..nkUInt64Lit, nkIntLit..nkInt64Lit:
+    result = BiggestFloat a.intVal
   else:
     raiseRecoverableError("cannot extract number from invalid AST node")
     #doAssert false, "getFloat"
diff --git a/compiler/lexer.nim b/compiler/lexer.nim
index 4bf50a359..c2b95c481 100644
--- a/compiler/lexer.nim
+++ b/compiler/lexer.nim
@@ -864,7 +864,9 @@ proc getCharacter(L: var TLexer, tok: var TToken) =
   inc(L.bufpos)               # skip '
   var c = L.buf[L.bufpos]
   case c
-  of '\0'..pred(' '), '\'': lexMessage(L, errGenerated, "invalid character literal")
+  of '\0'..pred(' '), '\'':
+    lexMessage(L, errGenerated, "invalid character literal")
+    tok.literal = $c
   of '\\': getEscapedChar(L, tok)
   else:
     tok.literal = $c