zephir-lang / zephir

Zephir is a compiled high-level language aimed to ease the creation of C-extensions for PHP
https://zephir-lang.com
MIT License
3.31k stars 466 forks source link

Runtime error with leading slash in "used" classes #651

Closed SliceOfLife closed 3 years ago

SliceOfLife commented 10 years ago

If I wrote a leading slash in use definition like this:

namespace Project;

use \Phalcon\Config;

class TestClass
{

    public static function doSomething()
    {
        var_dump(new Config());
    }

}

on runtime I got an error:

Fatal error: Class '\phalcon\config' not found in ...

PHP allow this syntax, but if the Zephir doesn't, it's a good reason to add a compiler warning, I think.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/6505517-runtime-error-with-leading-slash-in-used-classes?utm_campaign=plugin&utm_content=tracker%2F280146&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F280146&utm_medium=issues&utm_source=github).
ovr commented 10 years ago

I did'nt test It but i think this bug is caused byslash Zephir is not php

Please use

use Phalcon\Config;

without slash!

Thx for bug report :+1: