DEVSENSE / Phalanger

PHP 5.4 compiler for .NET/Mono frameworks. Predecessor to the opensource PeachPie project (www.peachpie.io).
http://v4.php-compiler.net/
Apache License 2.0
381 stars 92 forks source link

Overriding offsetGet in class that implements ArrayAccess throws internal error when parsing to pure+ mode #51

Closed robertleeplummerjr closed 8 years ago

robertleeplummerjr commented 9 years ago

the implementation is very simple:

public class Test implements ArrayAccess {
    public function &offsetGet( $offset )
    {
        return $this->__get( $offset );
    }
}

The actual code is here: https://github.com/robertleeplummerjr/redbean/blob/master/RedBeanPHP/OODBBean.php The command that triggers it: https://github.com/robertleeplummerjr/redbean.net/blob/master/build.bat

The error:

error PHP2007: Internal error! 
Please, report this bug via http://phalanger.codeplex.com/workitem/list/basic.
Additional information: 
Method 'offsetGet' in type 'RedBeanPHP.OODBBean' from assembly 'RedBean, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
   at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
   at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
   at System.Reflection.Emit.TypeBuilder.CreateType()
   at PHP.Core.Reflection.PhpType.Bake()
   at PHP.Core.Reflection.PureCompilationUnit.Bake()
   at PHP.Core.Reflection.PureCompilationUnit.Compile(IEnumerable`1 sourceFiles, PureAssemblyBuilder assemblyBuilder, CompilationContext context, Encoding encoding)
   at PHP.Core.Emit.PureAssemblyBuilder.Build(IEnumerable`1 sourceFiles, CompilationContext context)
   at PHP.Core.ApplicationCompiler.Compile(ApplicationContext applicationContext, CompilerConfiguration config, ErrorSink errorSink, CompilationParameters ps)
robertleeplummerjr commented 9 years ago

I might add, aside from this little issue, the whole thing works stunningly :)

robertleeplummerjr commented 9 years ago

After a little search, it looks like this is intended: https://github.com/DEVSENSE/Phalanger/blob/master/Source/Core/SPL/ArrayAccess.cs#L897

Any way actually have this implemented?

robertleeplummerjr commented 8 years ago

Any comment on the offsetGet?

jakubmisek commented 8 years ago

The issue is, your override does not match its base declaration (you return reference &) and compiler does not handle it well.

jakubmisek commented 8 years ago

should be fixed in 630fdbd668aa4d92930b66c0f08c41243af0af54

robertleeplummerjr commented 8 years ago

Nice! Thanks Jakub.

On Wed, Dec 30, 2015 at 11:51 AM, Jakub Míšek notifications@github.com wrote:

Closed #51 https://github.com/DEVSENSE/Phalanger/issues/51.

— Reply to this email directly or view it on GitHub https://github.com/DEVSENSE/Phalanger/issues/51#event-502909131.

Robert Plummer