-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Astgen: more unreachable checks #9645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have only some uses of expr()
been replaced with reachableExpr()
? It seems to me that every nearly every usage of expr()
needs to check if the expr()
is noreturn. I wonder if renaming expr()
to exprMaybeNoReturn()
and reachableExpr()
to expr()
would be the best way forward.
Note that the current reachableExpr()
also should be updated to use GenZir.endsWithNoReturn()
.
On further investigation, I think the only place where we wouldn't be able to use the semantics of the current |
Though now I've remembered about #3257 and wonder if we're on the totally wrong path here... |
b0f73a6
to
1a1624e
Compare
Note: if we apply these checks wherever technically possible this would make the following pattern fail to compile: pub const ensureCapacity = @compileError("deprecated for ensureUnusedCapacity and ..."); however, this could be worked around by wrapping the pub const ensureCapacity = {
@compileError("deprecated...");
};
// or
pub fn ensureCapacity(self: *Self, new_capacity: usize) !void {
@compileError("deprecated...");
} Applying these checks wherever possible would certainly be the most consistent approach IMO, and I don't find the workarounds too unpalatable. This feels quite arbitrary though... |
const result_inst = try expr(gz, scope, rl, node); | ||
if (gz.refIsNoReturn(result_inst)) { | ||
return gz.astgen.failNodeNotes(src_node, "unreachable code", .{}, &[_]u32{ | ||
try gz.astgen.errNoteNode(node, "control flow is diverted here", .{}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happened to this nice error note?
Also fixes #9630