Skip to content

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

@48cf

Description

@48cf

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions