Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions message-index/messages/GHC-21926/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Version number or non-alphanumeric character in package name
summary: Package imports may only consist of alphanumeric characters, and must omit the version.
severity: error
introduced: 9.6.1
extension: PackageImports
---

Version number or non-alphanumeric character in the package. Alphanumeric characters are letters and numbers, as defined by `Data.Char.isAlphaNum`.
Copy link
Collaborator

@Bodigrim Bodigrim Feb 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit incomplete: a package name can include dashes, even while Data.Char.isAlphaNum '-' = False.

The actual function GHC uses to validate package names is

looksLikePackageName = all (all isAlphaNum <&&> not . (all isDigit)) . split '-'

So probably something like "Each of dash-separated components of package name must consist of alphanumeric characters (as defined by Data.Char.isAlphaNum), at least one of which is not a digit". What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply. Sounds good! Changed the code 👍

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you push anything? I don't see any changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, rookie mistake. Pushed as f1fde5c (#514).

Apologies for the inconvenience.

Note that you will also see this error if the package name consists only of digits.
The package name in this case refers to the one mentioned in an import when using the `PackageImports` language extension.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# LANGUAGE PackageImports #-}

module NonAlphanumericCharacterNameInPackage where

import "some-existing-package" Package.With.Non.Alphanumeric.Characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# LANGUAGE PackageImports #-}

module NonAlphanumericCharacterNameInPackage where

import "&*$^%!@()" Package.With.Non.Alphanumeric.Characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: Non-alphanumeric characters in the package name
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# LANGUAGE PackageImports #-}

module VersionNameInPackage where

import "some-package" Package.With.Version
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{-# LANGUAGE PackageImports #-}

module VersionNameInPackage where

import "some-package-0.1.2.3" Package.With.Version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: Version number in package name
---