| author | |
| committer | |
| log | fe0c6a3df9480cc3d0be7412cd24bba4366c18a1 |
| tree | eabeaeb90961c4c7ad8abe40b85339ad4d4a281d |
| parent | fa1ea6062b172e75674353ee19857db9046ec9ee |
closes #902 files changed, 8 insertions(+), 2 deletions(-)
src/errmsg.cpp+5-2| ... | @@ -80,9 +80,12 @@ ErrorMsg *err_msg_create_with_line(Buf *path, int line, int column, | ... | @@ -80,9 +80,12 @@ ErrorMsg *err_msg_create_with_line(Buf *path, int line, int column, |
| 80 | int line_start_offset = line_offsets->at(line); | 80 | int line_start_offset = line_offsets->at(line); |
| 81 | int end_line = line + 1; | 81 | int end_line = line + 1; |
| 82 | int line_end_offset = (end_line >= line_offsets->length) ? buf_len(source) : line_offsets->at(line + 1); | 82 | int line_end_offset = (end_line >= line_offsets->length) ? buf_len(source) : line_offsets->at(line + 1); |
| 83 | int len = line_end_offset - line_start_offset - 1; | ||
| 84 | if (len < 0) { | ||
| 85 | len = 0; | ||
| 86 | } | ||
| 83 | 87 | ||
| 84 | buf_init_from_mem(&err_msg->line_buf, buf_ptr(source) + line_start_offset, | 88 | buf_init_from_mem(&err_msg->line_buf, buf_ptr(source) + line_start_offset, len); |
| 85 | line_end_offset - line_start_offset - 1); | ||
| 86 | 89 | ||
| 87 | return err_msg; | 90 | return err_msg; |
| 88 | } | 91 | } |
test/run_tests.cpp+3| ... | @@ -1680,6 +1680,9 @@ c_import { | ... | @@ -1680,6 +1680,9 @@ c_import { |
| 1680 | )SOURCE", 2, ".tmp_source.zig:2:1: error: C import failed", | 1680 | )SOURCE", 2, ".tmp_source.zig:2:1: error: C import failed", |
| 1681 | ".h:1:10: error: 'bogus.h' file not found"); | 1681 | ".h:1:10: error: 'bogus.h' file not found"); |
| 1682 | 1682 | ||
| 1683 | add_compile_fail_case("empty file", "", | ||
| 1684 | 1, ".tmp_source.zig:1:1: error: missing export declaration and output name not provided"); | ||
| 1685 | |||
| 1683 | } | 1686 | } |
| 1684 | 1687 | ||
| 1685 | static void print_compiler_invocation(TestCase *test_case) { | 1688 | static void print_compiler_invocation(TestCase *test_case) { |