summary refs log tree commit diff stats
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-09-27 07:11:21 +0300
committerGitHub <noreply@github.com>2024-09-27 06:11:21 +0200
commit1bd5a4a99ed3fc6a77c3f8927d2d2292203af328 (patch)
tree913e9d4133313b4ad6126db069cb486c43698fce
parenta27542195c9ba760d58e9d1e977313bc322a1ede (diff)
downloadNim-1bd5a4a99ed3fc6a77c3f8927d2d2292203af328.tar.gz
render float128 literals (#24182)
fixes #23639

Not sure if these are meant to be supported but it's better than
crashing.
-rw-r--r--compiler/renderer.nim5
-rw-r--r--tests/macros/tastrepr.nim7
2 files changed, 12 insertions, 0 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index 19df22326..cc07c0c2d 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -442,6 +442,11 @@ proc atom(g: TSrcGen; n: PNode): string =
       result = $n.floatVal & "\'f64"
     else:
       result = litAux(g, n, (cast[ptr int64](addr(n.floatVal)))[], 8) & "\'f64"
+  of nkFloat128Lit:
+    if n.flags * {nfBase2, nfBase8, nfBase16} == {}:
+      result = $n.floatVal & "\'f128"
+    else:
+      result = litAux(g, n, (cast[ptr int64](addr(n.floatVal)))[], 8) & "\'f128"
   of nkNilLit: result = "nil"
   of nkType:
     if (n.typ != nil) and (n.typ.sym != nil): result = n.typ.sym.name.s
diff --git a/tests/macros/tastrepr.nim b/tests/macros/tastrepr.nim
index 668904cae..96a37c7a2 100644
--- a/tests/macros/tastrepr.nim
+++ b/tests/macros/tastrepr.nim
@@ -24,6 +24,9 @@ for i, (x, y) in pairs(data):
 var (a, b) = (1, 2)
 type
   A* = object
+
+var t04 = 1.0'f128
+t04 = 2.0'f128
 '''
 """
 
@@ -49,3 +52,7 @@ echoTypedAndUntypedRepr:
     discard
   var (a,b) = (1,2)
   type A* = object # issue #22933
+
+echoUntypedRepr:
+  var t04 = 1'f128
+  t04 = 2'f128