Skip to content

Improve error message for non-ASCII characters in extension versions #12836

@benodiwal

Description

@benodiwal

Currently, when invalid non-ASCII characters are used in extension version declarations in dune-project files, users get a generic error message:

  File "dune-project", line 2, characters 14-14:
  (using menhir è)
  Error: Invalid dune-project file

This happens because non-ASCII characters fail at the s-expression parsing level before reaching version validation.

Expected behavior:

The error should be similar to what we show for (lang dune ...) declarations:

  Error: Invalid version. Version must be two numbers separated by a dot.
  Hint: using menhir 2.1

Current behavior:

  - ASCII invalid versions: `(using menhir Ali)` - Shows clear error message
  - Non-ASCII versions: `(using menhir è)` - Shows generic "Invalid dune-project file"

Context:

This issue was identified while implementing PR #12833. The s-expression parser rejects non-ASCII characters in atoms before the version decoder can provide a helpful error message.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions