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

Interpreter: cast proc call arguments to proc arg types #12375

Merged
merged 7 commits into from
Aug 19, 2022

Conversation

asterite
Copy link
Member

Fixes #12350

Note that for the example in #12350 to work it also needs #12374 merged.

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:interpreter labels Aug 11, 2022
@asterite
Copy link
Member Author

It seems Fiber#@proc is of type Proc(Nil) | Proc(Void) 😅 . I think those two types should be unified.

I'll try to fix it here too... that shouldn't happen.

@asterite
Copy link
Member Author

Actually, I'll just fix the interpreter for now.

@asterite
Copy link
Member Author

I can confirm #12388 makes this work without the workaround, so we might want to merge that one first.

@asterite asterite force-pushed the interpreter/cast-proc-call-args branch from 9eb89ba to f1dd841 Compare August 14, 2022 18:06
@asterite
Copy link
Member Author

I just undid the workaround. Let's see if CI passes now :-)

@asterite
Copy link
Member Author

CI failed and I have a fix for this. But I found out that a lot more primitive calls are broken if they happen inside a closure, so I'm going to do a general fix for that.

@asterite
Copy link
Member Author

So, the last non-merge commit is doing this. If you had code like this:

struct Enum
  def foo
    ->{
      value
    }
  end
end

enum Color
  Red
  Green
end

p Color::Green.foo.call

the "scope" (the type of self) inside the proc literal was incorrectly Program instead of Enum (or Color) in this case. This affected all primitive calls that happened without a receiver in a proc literal, so it was affecting Proc#call and probably many others. The last commit preserves the correct scope inside proc literals.

@straight-shoota straight-shoota added this to the 1.6.0 milestone Aug 19, 2022
@asterite asterite merged commit 13c6166 into master Aug 19, 2022
@asterite asterite deleted the interpreter/cast-proc-call-args branch August 19, 2022 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:interpreter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interpreter: Reached the unreachable with athena-validator callback constraint
3 participants