We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5ca7066 commit 39dc8b3Copy full SHA for 39dc8b3
1 file changed
src/example.zig
@@ -191,13 +191,17 @@ pub const Value = union(enum) {
191
}
192
193
pub fn fromIntegerLiteral(bytes: []const u8) Value {
194
- _ = bytes;
195
- return .{ .int = .{ .value = 0 } };
+ const num = std.fmt.parseInt(i64, bytes, 10) catch {
+ return .{ .err = "error parsing int" };
196
+ };
197
+ return .{ .int = .{ .value = num } };
198
199
200
pub fn fromFloatLiteral(bytes: []const u8) Value {
- return .{ .float = .{ .value = 0 } };
201
+ const num = std.fmt.parseFloat(f64, bytes) catch {
202
+ return .{ .err = "error parsing float" };
203
204
+ return .{ .float = .{ .value = num } };
205
206
207
pub fn fromBooleanLiteral(b: bool) Value {
0 commit comments