Closed zenspider closed 9 years ago
Is this a regression or something that never worked in maglev ? Assumming it never worked, The runtime implementation of "def" wants to send #method_added to the class, but in this case there is no class at the top level . So perhaps NilClass needs an implementation of method_added which does nothing ?
A generic method_added exists. The error message is confusing, I think. Here is the definition of compileIn:rubyMethod (from src/packages/Maglev.package/RubyCompiler.class/instance/compileIn.rubyMethod..st)
*maglev-runtime
compileIn: aClass rubyMethod: aNode
"called from generated code"
| cls selPrefix envId |
cls := aClass ifNil:[ Object "for irb" ].
envId := 1"__callerEnvId" .
selPrefix := self compileSelector: nil inClass: cls
rubyMethod: aNode env: envId .
selPrefix ifNotNil:[
"ruby_selector_suffix dependent , use perform to bypass protection"
aClass with: selPrefix perform: #'method_added#1__' env: 1 .
].
^ nil "per ruby specs, a 'def' returns nil"
I think the problem is that we compile in cls
(in case aClass
is nil, this is set to be Object
), but then we send method_added to aClass
I've pushed a potential fix, let's see if Travis is happy with it (it's late, and I'm too tired to wait for the results locally)
works fine, but:
fails with:
I don't have the chops to dig into this solo yet. Here's the relevant trace: