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

compiler internals: AST_STMT_FUNCTION is weird #514

Open
Akuli opened this issue Aug 17, 2024 · 0 comments
Open

compiler internals: AST_STMT_FUNCTION is weird #514

Akuli opened this issue Aug 17, 2024 · 0 comments

Comments

@Akuli
Copy link
Owner

Akuli commented Aug 17, 2024

In the Jou compiler, an AstStatement with kind set to AST_STMT_FUNCTION works like this:

jou/src/jou_compiler.h

Lines 278 to 281 in 6171948

struct AstFunction {
AstSignature signature;
AstBody body; // empty body means declaration, otherwise it's definition
};

This is not a good idea. Maybe it was at some point, but now I only see this as a source of bugs.

Instead, declare and def statements should be separated clearly, e.g. AST_DECLARE_FUNC (declare statement) and AST_DEFINE_FUNC (def statement). The AstFunction struct would be renamed to something like AstFunctionDef and it would only be used for def. A declare can simply use an AstSignature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant