Skip to content

Quoted component names containing spaces are impossible to refer to #12207

Description

@leana8959

Describe the bug
In the library, executable or test section it is possible to define a library with name within quotes.
By quoting the name, the library name can contain spaces.

When a library name contains spaces, it is impossible to refer to it in a build-depends fields because quotes are not allowed.
It is also impossible to refer to it in the CLI.

Cabal doesn't stop the user from quoting component name, nor from putting spaces.

There are in total only roughly 78 cabal files that does this on Hackage.

To Reproduce
Steps to reproduce the behavior:

TL;DR:

  • Add a trailing space to my-lib, and you won't be able to refer to it in the executable.
    It is not possible to put quotes in the build-depends field.

    Building the executable when the executable doesn't depend on the library would work.
    There's no hard parse error.

  • Add a trailing space to my-exe, and the executable will have a space in its name.

    Here's a silly example:

    Preprocessing library 'my-lib' for quote-component-name-repr-0.1.0.0...
    Building library 'my-lib' for quote-component-name-repr-0.1.0.0...
    Configuring executable '" m y - e x e "' for quote-component-name-repr-0.1.0.0...
    Preprocessing executable '" m y - e x e "' for quote-component-name-repr-0.1.0.0...
    Building executable '" m y - e x e "' for quote-component-name-repr-0.1.0.0...
    [1 of 1] Compiling Main
    [2 of 2] Linking dist-newstyle/build/x86_64-linux/ghc-9.10.3/quote-component-name-repr-0.1.0.0/x/" m y - e x e "/build/ m y - e x e / m y - e x e
    

Expected behavior

Quotes in component names should be a hard parse error.

System information

  • Operating system: NixOS 26.05
  • cabal: 10aed4e,
  • ghc: 9.10.3 from nixpkgs

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions