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

fix assert on self-referencing function ptr field #797

Merged
merged 1 commit into from Feb 28, 2018
Merged

fix assert on self-referencing function ptr field #797

merged 1 commit into from Feb 28, 2018

Conversation

bnoordhuis
Copy link
Contributor

The construct struct S { f: fn(S) void } is not legal because structs
are not copyable but it should not result in an ICE.

Fixes #795.

Best possible fix or not? There is existing logic for detecting self-recursive types but this isn't quite that. Suggestions welcome.

The construct `struct S { f: fn(S) void }` is not legal because structs
are not copyable but it should not result in an ICE.

Fixes #795.
@@ -1670,6 +1670,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
if (struct_type->data.structure.is_invalid)
return;

if (struct_type->data.structure.zero_bits_loop_flag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm this doesn't seem right to me. if we return from resolve_struct_zero_bits then either zero_bits_loop_flag should be false or is_invalid should be true. Let me poke at it.

@andrewrk andrewrk merged commit 90598b4 into ziglang:master Feb 28, 2018
@andrewrk
Copy link
Member

The resolve_*_zero_bits and resolve_*_type functions are brittle and I need to rework how all that is handled. My plan is to do a better implementation in the self hosted compiler and then, if necessary, port the better implementation back to the c++ compiler.

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

Successfully merging this pull request may close these issues.

Assertion failure when declaring struct S { m: fn(self: S) }
2 participants