phug-php / phug

Phug - The Pug Template Engine for PHP
https://phug.selfbuild.fr
MIT License
62 stars 3 forks source link

Wrong debug info on mixin call error #40

Closed rodion-k closed 5 years ago

rodion-k commented 5 years ago

Hello,

I encountered an issue with the following code: main.pug

include test
+foo

test.pug

div
div
div

I expected to get error in main file on line 2. But I actually get:

InvalidArgumentException in /src/test.pug:
Unknown foo mixin called. on line 3, offset 1

    1 | div
    2 | div
>   3 | div
--------^

If mixin is called in tag, error message is almost correct:

include test
div
    +foo
InvalidArgumentException:
Unknown foo mixin called. on line 2, offset 1

    1 | include test
>   2 | div
--------^
    3 |   +foo

Thanks!

kylekatarnls commented 5 years ago

In fact we works with debug points, and this is in both case the last point successfully reached before the error was raised. It seems we need to add a debug point just before mixin call to get the accurate position.

kylekatarnls commented 5 years ago

Fixed in https://github.com/phug-php/compiler/releases/tag/0.5.25

Thanks.