Closed rlinoz closed 3 years ago
Hey, thanks for the bug report.
Your examples show two different issues:
public func foo(_ bar: Double?) -> Double {
return bar ?? 0.0
}
This one failed because Swift treats the 0.0
as an autoclosure, and Gryphon didn't know how to interpret that. This should be fixed now.
private struct Foo {
var balance: Double?
}
public func baz() {
let f = Foo()
f.balance = 32.0
}
This one actually fails because Swift can't compile it, since we can't mutate the f
variable because it's a let
. If we change f
to be a var
, Swift compiles it successfully and Gryphon translates it without errors. That said, Gryphon's error message for this case wasn't helpful, so I also improved the way it handles the unexpected cases.
As usual, you can try this now if you want with brew install vinivendra/gryphon/gryphon --HEAD
, or wait for the fix to be publicly released tomorrow night :)
Describe the bug Apparently Gryphon is having trouble understanding Doubles and Floats
How to reproduce it If we run this code:
We get
error: Failed to convert float literal expression (failed to translate SwiftSyntax node). return bar ?? 0.0
Also if we assign a variable of a struct to a Double value it will give a similar error:
And we get this error:
Failed to convert float literal expression (failed to translate SwiftSyntax node). f.balance = 32.0
Your environment (please complete the following information):