Skip to content
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

Distinguish between an empty function body and lack of one #14

Open
48cf opened this issue Aug 26, 2023 · 0 comments
Open

Distinguish between an empty function body and lack of one #14

48cf opened this issue Aug 26, 2023 · 0 comments
Labels
bug Something isn't working workaround exists

Comments

@48cf
Copy link
Collaborator

48cf commented Aug 26, 2023

Currently, in the bootstrap compiler, we don't distinguish an empty function body from a non-existent one. This may lead to confusing compile errors such as:

fn main() noreturn {
	_ = fn() void {}.&;
	unreachable;
}
thread 15440 panic: Can't take the addr of type_idx
...
[snip]/newton/bootstrap/sema.zig:1500:48: 0x2b05e8 in semaASTExpr (bootstrap)
                else => |other| std.debug.panic("Can't take the addr of {s}", .{@tagName(other)}),
                                               ^

A fix for that is obviously to distinguish between those 2 states in the parser properly, but inserting _ = undefined in the anonymous function is enough as a temporary workaround. This is a low priority issue.

@N00byEdge N00byEdge added bug Something isn't working workaround exists labels Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working workaround exists
Projects
None yet
Development

No branches or pull requests

2 participants