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

RT#102994: State init vars if not set on first pass #1539

Closed
wants to merge 2 commits into from

Conversation

jstuder-gh
Copy link
Contributor

Given the following subroutine:

sub f($x) {
    return if $x;
    state $y = 5;
    $y;
}

Previously, $y would only be assigned a value if the statement is
reached on the first invocation of the static frame. So if f(1) is called first,
each subsequent f(0) call returns (Any)

To address this, added an indicator on the static frame (in
corresponding MoarVM/JVM developments) and modified p6stateinit to take a var
and check whether it has been assigned to. If the assignment was not
reached in the first pass in the life of a static frame, the is_hll_init
value indicates that it requires HLL assignment the next time it is
encountered.

See RT#102994

Given the following subroutine:

    sub f($x) {
        return if $x;
        state $y = 5;
        $y;
    }

Previously, $y would only be assigned a value if the statement is
reached on the first invocation of the static frame.

To address this, added an indicator on the static frame (in
corresponding MoarVM development) and modified p6stateinit to take a var
and check whether it has been assigned to. If the assignment was not
reached in the first pass in the life of a static frame, the is_hll_init
value indicates that it requires HLL assignment the next time it is
encountered.

See [RT#102994](https://rt.perl.org/Public/Bug/Display.html?id=102994)
Modify p6stateinit to match the functionality of the MoarVM version.
@jstuder-gh
Copy link
Contributor Author

Relies on changes made in MoarVM/MoarVM#805 and Raku/nqp#418.

This change passes all the tests in the (MoarVM) spectest except one:

t/spec/S04-declarations/state.rakudo.moar 

which I assume is because of the modification to the MVMStaticFrame struct. I don't know how to update this test.

@jstuder-gh
Copy link
Contributor Author

This is not going to work (See MoarVM PR#805). Closing this now. I'll submit another PR at a later date if I create something that addresses the entire issue.

@jstuder-gh jstuder-gh closed this Feb 17, 2018
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.

1 participant