Skip to content

fix: report more than one uppercase root file instead of picking one at random - #6584

Open
prql-bot wants to merge 7 commits into
mainfrom
fix/ambiguous-root-module
Open

prql-bot wants to merge 7 commits into
mainfrom
fix/ambiguous-root-module

Conversation

@prql-bot

Copy link
Copy Markdown
Collaborator

prqlc compile <dir> picked the root module at random when more than one file in the directory starts with an uppercase letter. linearize_tree took the first such key of the source tree's HashMap, so with Project.prql (from a) and Other.prql (from b), six runs on main (0d4c6efe) printed SELECT * FROM b twice and SELECT * FROM a four times. This PR reports both candidates as an E0002 error instead:

[E0002] Error: Found more than one root module candidate:
 - Other.prql
 - Project.prql
↳ Hint: keep only one file starting with an uppercase letter in the root directory

The same check only looked at a path's first component, which is the directory name for a nested file. So Foo/bar.prql counted as an uppercase root, and Sales/orders.prql competed with Project.prql in the random pick. Now only files directly in the root directory count, which matches what the book's modules page says. I've tightened that page's sentence to say there must be exactly one such file.

A single file, or a tree with an empty-path root, is resolved as before.

linearize_tree had no tests. The three new unit tests in parser.rs cover one uppercase root next to an uppercase directory, two uppercase roots, and an uppercase directory with no root file. With the old check all three fail. cargo insta test -p prqlc --lib --test integration passes, including the CLI test that compiles tests/integration/project.

Found by the nightly code survey.

prql-bot and others added 4 commits November 20, 2026 06:52
…at random

When prqlc compile is given a directory with several root-level files
starting with an uppercase letter, the root module was the first match in
HashMap iteration order, so repeated runs compiled different files. Report
the candidates instead. Also only consider files directly in the root
directory, so a file inside an uppercase directory isn't taken as the root.

This branch has not been deployed

No deployments
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