| author | |
| committer | |
| log | 207862647c00ef824a6dd43be0bfc69d844fc075 |
| tree | 8410cf97d4bdcd5e240278eb19ed03461a720932 |
| parent | 1d92700d089eb2e225d1db6de780e4288fa68452 |
also codegen implement comparision with pure errors4 files changed, 16 insertions(+), 1 deletions(-)
src/codegen.cpp+3| ... | @@ -1269,6 +1269,9 @@ static LLVMValueRef gen_cmp_expr(CodeGen *g, AstNode *node) { | ... | @@ -1269,6 +1269,9 @@ static LLVMValueRef gen_cmp_expr(CodeGen *g, AstNode *node) { |
| 1269 | } else { | 1269 | } else { |
| 1270 | zig_unreachable(); | 1270 | zig_unreachable(); |
| 1271 | } | 1271 | } |
| 1272 | } else if (op1_type->id == TypeTableEntryIdPureError) { | ||
| 1273 | LLVMIntPredicate pred = cmp_op_to_int_predicate(node->data.bin_op_expr.bin_op, false); | ||
| 1274 | return LLVMBuildICmp(g->builder, pred, val1, val2, ""); | ||
| 1272 | } else { | 1275 | } else { |
| 1273 | zig_unreachable(); | 1276 | zig_unreachable(); |
| 1274 | } | 1277 | } |
std/std.zig+10-1| ... | @@ -158,7 +158,7 @@ pub fn parse_u64(buf: []u8, radix: u8) -> %u64 { | ... | @@ -158,7 +158,7 @@ pub fn parse_u64(buf: []u8, radix: u8) -> %u64 { |
| 158 | for (buf) |c| { | 158 | for (buf) |c| { |
| 159 | const digit = char_to_digit(c); | 159 | const digit = char_to_digit(c); |
| 160 | 160 | ||
| 161 | if (digit > radix) { | 161 | if (digit >= radix) { |
| 162 | return error.InvalidChar; | 162 | return error.InvalidChar; |
| 163 | } | 163 | } |
| 164 | 164 | ||
| ... | @@ -342,3 +342,12 @@ pub fn buf_print_f64(out_buf: []u8, x: f64, decimals: isize) -> isize { | ... | @@ -342,3 +342,12 @@ pub fn buf_print_f64(out_buf: []u8, x: f64, decimals: isize) -> isize { |
| 342 | 342 | ||
| 343 | len | 343 | len |
| 344 | } | 344 | } |
| 345 | |||
| 346 | #attribute("test") | ||
| 347 | fn parse_u64_digit_too_big() { | ||
| 348 | parse_u64("123a", 10) %% |err| { | ||
| 349 | if (err == error.InvalidChar) return; | ||
| 350 | unreachable{}; | ||
| 351 | }; | ||
| 352 | unreachable{}; | ||
| 353 | } |
test/self_hosted.zig+2| ... | @@ -1,3 +1,5 @@ | ... | @@ -1,3 +1,5 @@ |
| 1 | import "test_std.zig"; | ||
| 2 | |||
| 1 | #attribute("test") | 3 | #attribute("test") |
| 2 | fn empty_function() {} | 4 | fn empty_function() {} |
| 3 | 5 |
test/test_std.zig created+1| ... | @@ -0,0 +1 @@ | ||
| 1 | import "std.zig"; | ||