AstGen: implement compile error for useless locals

When a local variable has an initialization expression of type
'noreturn', emit a compile error. This brings this branch closer
to parity with master branch.
This commit is contained in:
Andrew Kelley
2021-06-25 19:43:01 -07:00
parent 527c55aa56
commit cffa22a658
2 changed files with 32 additions and 2 deletions

View File

@@ -4831,7 +4831,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ const a = return;
\\}
, &[_][]const u8{
"tmp.zig:2:5: error: unreachable code",
"tmp.zig:2:5: error: useless local constant",
"tmp.zig:2:15: note: control flow is diverted here",
});
cases.add("unreachable variable",