fix crash when constant inside comptime function has compile error

closes #625
This commit is contained in:
Andrew Kelley
2017-11-25 18:16:33 -05:00
parent 48ebb65cc7
commit a2afcae9ff
3 changed files with 45 additions and 4 deletions

View File

@@ -2343,4 +2343,23 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\pub extern fn foo(format: &const u8, ...);
,
".tmp_source.zig:2:9: error: expected type '&const u8', found '[5]u8'");
cases.add("constant inside comptime function has compile error",
\\const ContextAllocator = MemoryPool(usize);
\\
\\pub fn MemoryPool(comptime T: type) -> type {
\\ const free_list_t = @compileError("aoeu");
\\
\\ struct {
\\ free_list: free_list_t,
\\ }
\\}
\\
\\export fn entry() {
\\ var allocator: ContextAllocator = undefined;
\\}
,
".tmp_source.zig:4:25: error: aoeu",
".tmp_source.zig:1:36: note: called from here",
".tmp_source.zig:12:20: note: referenced here");
}