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

Fatal error at compilation when an extended/implemented class does not exist #1062

Closed
fezfez opened this issue Aug 21, 2015 · 6 comments
Closed

Comments

@fezfez
Copy link
Contributor

fezfez commented Aug 21, 2015

Hi,

I have this error

Argument 1 passed to Zephir\ClassDefinition::setExtendsClassDefinition() must be an instance of Zephir\ClassDefinition, instance of Zephir\ClassDefinitionRuntime given, called in /home/travis/build/fezfez/php-to-zephir/vendor/phalcon/zephir/Library/CompilerFile.php on line 755 and defined
/home/travis/build/fezfez/php-to-zephir/vendor/phalcon/zephir/Library/ClassDefinition.php:385
/home/travis/build/fezfez/php-to-zephir/vendor/phalcon/zephir/Library/CompilerFile.php:755
/home/travis/build/fezfez/php-to-zephir/vendor/phalcon/zephir/Library/Compiler.php:765
/home/travis/build/fezfez/php-to-zephir/vendor/phalcon/zephir/Library/Commands/CommandAbstract.php:101
/home/travis/build/fezfez/php-to-zephir/src/PhpToZephir/CodeValidator.php:28
/home/travis/build/fezfez/php-to-zephir/tests/Converter/ConverterBaseTest.php:91
/home/travis/build/fezfez/php-to-zephir/tests/Converter/Code/Oop/ExtendsAndImplementTest.php:134

I've found the errored line in 0.7.1

https://github.com/phalcon/zephir/blob/182c87d35201a8d4cb4c44c27955f325a1f73b43/Library/CompilerFile.php#L755
https://github.com/phalcon/zephir/blob/182c87d35201a8d4cb4c44c27955f325a1f73b43/Library/CompilerFile.php#L722

You can see the error in my travis build :

steffengy pushed a commit to steffengy/zephir that referenced this issue Aug 27, 2015
…ir-lang#1062

Generally runtime class definitions have several problems:
- interface validation of implemented methods is not possible
- eventually problems regarding ctor's/default property values
- eventual problems with method calls that depend on type information
@steffengy
Copy link
Contributor

Could you try using the development branch?

@lajosbencz
Copy link

I've just stumbled upon the same issue today, updated to the development branch and now compilation succeeds!

@fezfez
Copy link
Contributor Author

fezfez commented Aug 28, 2015

Using the dev branch throw an exception.

Zephir\CompilerException: Cannot locate interface Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface when implementing interfaces on Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass
at Library/ClassDefinition.php(1104)

@fezfez
Copy link
Contributor Author

fezfez commented Aug 28, 2015

@lajosbencz : Could you please submit a sample of your code ?

@steffengy
Copy link
Contributor

It's probably a simpler case only depending on class extension,

I think with interface extension you have the problem, that if it can't be evaluated on
runtime, zephir won't validate if a method is actually implemented
on the class implementing interfaces. I'm currently unsure if it's technically advisable
to allow that behavior and if it's trivially doable.

Generally it is advisable, to make sure classes / interface implementations
are known at compiletime (via autoloading, ...) to ensure not only better
validation of inheritance but also better code generation (better type-choices,
leading to better performance and less probability of bugs)

@fezfez
Copy link
Contributor Author

fezfez commented Aug 29, 2015

@steffengy : God point, the case happen on direct translation a package with php-to-zephir with a suggested package, i do have to ignore this class.

Thanks !

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

No branches or pull requests

3 participants