Skip to content

Conversation

@Alizter
Copy link
Collaborator

@Alizter Alizter commented Jan 27, 2026

At the moment we have two kinds of undefined package variable.

  1. The package is undefined.
  2. The package is defined, but the variable is undefined.

We raise the same error on both of these at the moment, but these two cases are actually distinct. The second should really be an error, but according to opam semantics the first should evaluate to the empty string, at least in string interpolation.

An example of where this comes up in the wild is here:
https://github.com/dra27/opam-repository/blob/b4c092154b06471b3ed5886716ff45e4e8f58c17/packages/ocaml/ocaml.5.5.0/opam#L38

The %{dkml-base-compiler:version}% variable's package doesn't exist unless the correct opam repository is available. Therefore in most cases opam evaluates this to the empty string.

This test demonstrates that we error on this behaviour and a future fix should make it evaluate to the empty string.

Part of the work on

Signed-off-by: Ali Caglayan <alizter@gmail.com>
@Alizter Alizter marked this pull request as ready for review January 27, 2026 12:00
@Alizter Alizter mentioned this pull request Jan 27, 2026
10 tasks
@Alizter Alizter changed the title test: undefined package variables test: variables of undefined packages Jan 27, 2026
@Alizter Alizter merged commit eb06957 into ocaml:main Jan 27, 2026
28 checks passed
@Alizter Alizter deleted the push-souwqnrkkrrm branch January 27, 2026 12:22
Alizter added a commit that referenced this pull request Jan 28, 2026
This test isn't testing the correct thing in the end, so I wish to
revert and try again.

Reverts #13465
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant