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

AST inlining breaks capture semantics #37

Open
smarr opened this issue Sep 21, 2016 · 1 comment
Open

AST inlining breaks capture semantics #37

smarr opened this issue Sep 21, 2016 · 1 comment
Labels
bug Fixes an issue, incorrect implementation
Milestone

Comments

@smarr
Copy link
Owner

smarr commented Sep 21, 2016

@eregon found a bug in the AST inlining. The following test does not result in the correct output:

class Test usingPlatform: platform = Value (
| private Array = platform kernel Array. |
)(
  public main: args = (
    | arr b |
    arr := Array new: 10.
    args from: 2 to: args size do: [ :arg | arg print. ' ' print ].

    'Correct Semantics' println.
    b := [ :i  |
        arr at: i put: [ i ]].
    1 to: 10 do: b.

    1 to: 10 do: [ :i  |
        (arr at: i) value println ].

    'Broken Semantics' println.
    1 to: 10 do: [ :i  |
        arr at: i put: [ i ]].

    1 to: 10 do: [ :i  |
        (arr at: i) value println ].
    ^ 0
  ) 
)
@smarr smarr added the bug Fixes an issue, incorrect implementation label Sep 21, 2016
@smarr
Copy link
Owner Author

smarr commented Sep 21, 2016

Since this is only a problem in case the lexical scope is captured, a first fix could simply disable the optimization when there is a nested block.

@smarr smarr added this to the later milestone Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes an issue, incorrect implementation
Projects
None yet
Development

No branches or pull requests

1 participant