Linguist: Perl 5 code being mistaken for Perl 6

Created on 23 May 2017  ·  16Comments  ·  Source: github/linguist

This is recognized as Perl 6, wrongly:

=head1 NAME

class

=cut

package PH;

use 5.010;

This is recognized as Perl 5:

=head1 NAME



=cut

package PH;

use 5.010;

Most helpful comment

@pchaigno May I submit one then? You mentioned adding a test to test/test_heuristics.rb, however there is already a test for loading samples and disambiguate _Perl_ | _Perl 6_ (lines 224-231). In this case, adding a minimal example to samples/Perl (like the ones posted here) causes tests to fail. With the change in heuristics.rb they pass again. So, is adding the sample enough?

All 16 comments

I don't get reliable results when i push this to github with changes, but this looks like it also is recognized as Perl 6, wrongly:

use 5.006;
use strict;
use warnings;

=head1

module

=cut

And removing module changes it to perl 5.

Forgot to mention, in both examples the files were Word.pm.

Looks like just swapping these conditionals to check for Perl 5 regex first will solve the issue.

And then the cases where the disambiguation gets it wrong, Perl 6 users always have the option to renaming the file to .pm6 extension.

https://github.com/github/linguist/blob/58ab593a64088be56e3323a9fb121fe0988bdb3c/lib/linguist/heuristics.rb#L348

^ That heuristic would false positive on anything using MooseX::Declare style perl-5 syntax anyway.

So yeah, +1 on inversion.

We'd welcome a pull request with a test (test/test_heuristics.rb) to implement that change :smiley:

Is it really worth it to have Perl 6 separated from Perl? It seems the only case where linguist tries to determine language version, no Python 3, Java 6 or things like that, and the amount of misclassifications seems significant.

Is it really worth it to have Perl 6 separated from Perl

Yes, considering it's an entirely different language. It's like C vs C++, except with poorer name.

@smola Perl 5 and Perl 6 are, as @zoffixznet put it, two entirely separate languages. To quote "Programming Perl":

That 6 is deceptive though; Perl 6 is really a “kid sister” language to Perl 5, and not just a major update to Perl 5 that version numbers have trained you to expect.

@pchaigno Do you know if this was in fact fixed? I've got a similar problem in a repository for a Perl 5 module which has its main file being incorrectly interpreted as Perl 6, making the repository also Perl 6 (funny enough, named p5-POD-Auto). Thanks!

@tessarin No, I don't think a pull request for the above proposed change was submitted.

@pchaigno May I submit one then? You mentioned adding a test to test/test_heuristics.rb, however there is already a test for loading samples and disambiguate _Perl_ | _Perl 6_ (lines 224-231). In this case, adding a minimal example to samples/Perl (like the ones posted here) causes tests to fail. With the change in heuristics.rb they pass again. So, is adding the sample enough?

May I submit one then?

@tessarin Sure, go ahead 😄

You mentioned adding a test to test/test_heuristics.rb, however there is already a test for loading samples and disambiguate _Perl_ | _Perl 6_ (lines 224-231).

Oh, right. In that case, yes, a sample is enough. Please add it in test/fixtures/Perl/ rather than in samples/ though. samples/ files should originate from "real" application. test/fixtures/ is for this kind of test-only example files.

Any chance that this will get fixed soon?

@sidyll well the pull request was already made and it was approved, but I'm not sure about how the review process works or the release frequency.

PR has been merged. I've been AFK for a week so need to do some catching up before I can make a new release. I can't say when this will be right now though.

Thank you @lildude!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucasrodes picture lucasrodes  ·  6Comments

etc0de picture etc0de  ·  5Comments

headupinclouds picture headupinclouds  ·  4Comments

BnSalahFahmi picture BnSalahFahmi  ·  3Comments

TimothyGu picture TimothyGu  ·  5Comments