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

Plain perl mistaken for Perl6 #2074

Closed
kentfredric opened this issue Feb 3, 2015 · 2 comments · Fixed by #2092
Closed

Plain perl mistaken for Perl6 #2074

kentfredric opened this issue Feb 3, 2015 · 2 comments · Fixed by #2092

Comments

@kentfredric
Copy link

I was forwarded here by github relating to a failure to highlight this document: https://gist.github.com/kentfredric/04b64a80c5d90eea2924

Repeated attempt to indicate what language it was using the file extension always resulted in it thinking I was using Perl6.

Looking into your heuristics ( as per #2042 ) I find this: https://github.com/github/linguist/blob/master/lib/linguist/heuristics.rb#L54-L57

disambiguate "Perl", "Perl6", "Prolog" do |data|
  if data.include?("use v6")
    Language["Perl6"]
  elsif data.include?("use strict")
    Language["Perl"]
  elsif data.include?(":-")
    Language["Prolog"]
  end
end

That perl heuristic is incredibly narrow and will exclude anything that is relying on strict to be injected by another pragma/module.

use Moose and use Moo both inject strict.
use 5.xxx injects strict where "xxx" can be converted to an integer that is 12 or greater.

Though it seems to me, a good heuristic to use in addition to use strict would be :

use\s+v?5\.

Which should catch any perl5 document that is using an explicit perl version requirement.

As would:

^#![^ ]*perl($|[^6])

( Because "perl" may never assume to mean "perl6", and may only imply perl5 )

@bkeepers
Copy link
Contributor

bkeepers commented Feb 9, 2015

Thanks for reporting the issue!

Though it seems to me, a good heuristic to use in addition to use strict would be…

Cool, I added that in #2092

^#![^ ]*perl($|[^6])

The shebang strategy, which runs before the heuristics, should properly detect the perl version.

@arfon
Copy link
Contributor

arfon commented Feb 27, 2015

This was fixed in #2092

@arfon arfon closed this as completed Feb 27, 2015
dbsrgits-sync pushed a commit to Perl5/DBIx-Class that referenced this issue Apr 28, 2016
Port of mojolicious/mojo@19cdf772
Before this clarification the project listed as 7% Perl6 code >.<

The explicit listing is needed, as there apparently won't be a fix
within Github itself any time soon:
github-linguist/linguist#2149 (comment)
github-linguist/linguist#2781 (comment)
github-linguist/linguist#2074 (comment)

Language names sourced from:
https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
gamogamze15 pushed a commit to gamogamze15/linguist that referenced this issue Mar 18, 2024
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants