-
Notifications
You must be signed in to change notification settings - Fork 48
Fix the incorrect display of the column and line in errors. #79
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR! I would use a custom exception constructor (that can use a trait or a parent class) to compute the correct line, column, marker/arrow position etc. rather than a trait in the Can you update your patch this way please? If you don't have time, I can do it for you. |
@Hywan With such a signature?
|
Or maybe: $message = \sprintf('...', ...$args);
throw SomeErr::fromOffset($message, string $sources, int $offset); |
What about: class UnrecognizedToken extends Exception
{
…
public function __construct($code, $text, $byteOffset)
{
// …
parent::__construct($message, $code, $args);
}
} Notice that Thoughts? |
This will make it impossible to reuse the exception with arguments that are different from those specified in the constructor. And this is a violation of backward compatibility. Is such an improvement of such changes worthwhile? |
Or add a static method on class UnrecognizedToken extends Exception
{
public static function blabla(…)
{
// $message
return new self($message, …);
}
} |
This I suggested above. Just now there is no time to realize =\ I think I'll fix it this week. |
Heh, sorry :-). |
@Hywan ping? |
@SerafimArts PR was closed for a reason? |
@Pierozi for me it became not relevant. I had to fork the project and slightly rewrite it: https://github.com/railt/compiler/network |
We are still interested by the PR though… Can you reopen it please? |
you can still get the code of the PR, in order to recreate your branch
|
Done |
In any case, in this PR I did not take into account the behavior of |
Thanks for reopening! |
Fixes "Incorrect calculation of line and position in utf-8 files" issue
Unrecognized token:
Unexpected token:
😸