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 rakudo/rakudo#2965 #1116

Merged
merged 1 commit into from Jun 9, 2019
Merged

Conversation

kazcw
Copy link
Contributor

@kazcw kazcw commented Jun 8, 2019

Exception rather than segfault in response to an attempt to HAS a type before it's defined (rakudo/rakudo#2965)

@kazcw
Copy link
Contributor Author

kazcw commented Jun 8, 2019

After this patch, the following throws 3 compile-time exceptions instead of segfaulting:

class OopsUnion is repr(「CUnion」) { HAS OopsUnion $.more; }
class OopsStruct is repr(「CStruct」) { HAS OopsStruct $.more; }
class OopsPPStruct is repr(「CPPStruct」) { HAS OopsPPStruct $.more; }

I'm trying to figure out how to write a test that passes when it throws an exception at compile time

@MasterDuke17
Copy link
Contributor

throws-like in an EVAL maybe?

kazcw added a commit to kazcw/rakudo that referenced this pull request Jun 8, 2019
This will segfault until it's built on MoarVM/MoarVM#1116
kazcw added a commit to kazcw/rakudo that referenced this pull request Jun 8, 2019
This will segfault until it's built on MoarVM/MoarVM#1116
@kazcw
Copy link
Contributor Author

kazcw commented Jun 8, 2019

Hm, this causes the new exception to be thrown upon attempts to HAS objects of types that aren't CArray/CUnion/CP*STruct. I should move the check into all the appropriate switch branches so it fails right for the never-HASable cases...

You can't HAS a type before it's defined, whether it be stubbed or an
attempt at recursive HASation. This changes the penalty from segfaulty
death to merciful exception.
@kazcw kazcw force-pushed the cant-has-incomplete-type branch from 3645bc0 to 36469a6 Compare June 8, 2019 16:46
@kazcw
Copy link
Contributor Author

kazcw commented Jun 8, 2019

Ok, I made the check more fine grained so the new error will never occur when a null-derived pointer dereference didn't before

@jnthn jnthn merged commit 4e2ee39 into MoarVM:master Jun 9, 2019
kazcw added a commit to kazcw/rakudo that referenced this pull request Jun 9, 2019
This will segfault until it's built on MoarVM/MoarVM#1116
ugexe pushed a commit to rakudo/rakudo that referenced this pull request Jun 9, 2019
This will segfault until it's built on MoarVM/MoarVM#1116
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.

None yet

3 participants