summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/ast.nim2
-rw-r--r--tests/misc/tlowhigh.nim6
2 files changed, 7 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/tests/misc/tlowhigh.nim b/tests/misc/tlowhigh.nim
index 61a7bfaed..76f298a4a 100644
--- a/tests/misc/tlowhigh.nim
+++ b/tests/misc/tlowhigh.nim
@@ -11,4 +11,8 @@ var y: range[-1'f64..1'f64]
 doAssert y.low == -1'f64
 doAssert y.high == 1'f64
 doAssert y.type.low == -1'f64
-doAssert y.type.high == 1'f64
\ No newline at end of file
+doAssert y.type.high == 1'f64
+
+# bug #11972
+var num: uint8
+doAssert num.high.float == 255.0