render float128 literals (#24182)

fixes #23639

Not sure if these are meant to be supported but it's better than
crashing.
This commit is contained in:
metagn
2024-09-27 07:11:21 +03:00
committed by GitHub
parent a27542195c
commit 1bd5a4a99e
2 changed files with 12 additions and 0 deletions

View File

@@ -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

View File

@@ -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