Skip to content

Commit

Permalink
render float128 literals (#24182)
Browse files Browse the repository at this point in the history
fixes #23639

Not sure if these are meant to be supported but it's better than
crashing.
  • Loading branch information
metagn authored Sep 27, 2024
1 parent a275421 commit 1bd5a4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/renderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/macros/tastrepr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
"""

Expand All @@ -49,3 +52,7 @@ echoTypedAndUntypedRepr:
discard
var (a,b) = (1,2)
type A* = object # issue #22933

echoUntypedRepr:
var t04 = 1'f128
t04 = 2'f128

0 comments on commit 1bd5a4a

Please sign in to comment.