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

Exception "Encountered unexpected character" is thrown in case of non-latin variable names. #226

Open
kberov opened this issue Jun 22, 2018 · 1 comment

Comments

@kberov
Copy link

kberov commented Jun 22, 2018

I have a project in which I experiment with the ability of Perl to use unicode characters for naming variables and subroutines. I also use Test::Perl::Critic to maintain high quality of the code. After grepping from where the error comes I found that it is because PPI cannot parse such characters.

The following code fails with the following exception:

has domain => sub {
  my $дом = $_[0]->req->headers->host;
  $дом =~ s/(\:\d+)$//;    # remove port
  return $дом;
};
not ok - Test::Perl::Critic for "lib/Slovo/Controller.pm"
#   Failed test 'Test::Perl::Critic for "lib/Slovo/Controller.pm"'
#   at /home/berov/perl5/perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1/Test/Perl/Critic.pm line 121.
# 
# Perl::Critic had errors in "lib/Slovo/Controller.pm":
# 	Can't parse code: Encountered unexpected character '208'

The exception is thrown from
perlbrew/perls/perl-5.26.1/lib/site_perl/5.26.1/PPI/Token/Whitespace.pm:437
The Version of PPI is: 1.236

@choroba
Copy link

choroba commented Nov 23, 2018

It breaks if you use non-ascii characters in unquoted LHS of the fat comma, too:

use utf8;
my %czech_to_english = ( kůň => 'horse' );

robertwenner added a commit to robertwenner/comics that referenced this issue Mar 1, 2021
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

2 participants