Skip to content

fix(idl): recognize equivalent paths for pragma once - #67

Merged
SandraK82 merged 2 commits into
zero-objects:mainfrom
MatthewS8:pragma-once-fix
Nov 12, 2026
Merged

SandraK82 merged 2 commits into
zero-objects:mainfrom
MatthewS8:pragma-once-fix

Conversation

@MatthewS8

@MatthewS8 MatthewS8 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

fix(idl): recognize equivalent paths for pragma once

Summary

Fixes #65.

When a file containing #pragma once is included through different paths, the filesystem loader now identifies those paths using their canonical filesystem identity. The preprocessor uses that identity for include guards and cycle detection while retaining the resolved path for diagnostics, include resolution, and dependency tracking. Virtual loaders continue to use exact-name identity by default.

Specification Reference

N/A — #pragma once is a supported extension; this change does not claim IDL standard compliance for it.

Test Coverage

  • New tests written for the new code.
  • Existing tests account for the change.
  • cargo test --workspace passed locally.
  • cargo clippy --workspace --all-targets -- -D warnings passed locally.
  • cargo fmt --all -- --check passed locally.

Regression coverage includes direct and transitive aliases, distinct files with the same basename, root-file aliases, cycles, Windows case variants, Unix symlinks and non-UTF-8 targets, and virtual loader identities.

On Linux with Rust 1.97.1, workspace formatting and Clippy passed. The focused tests also passed:

cargo test -p zerodds-idl-parse -p zerodds-idl-compose

The full workspace test suite was not completed.

Breaking Change?

  • No.
  • Yes — migration notes added to the crate changelog.

The new FileLoader::identity method has a default implementation.

Checklist

  • Conventional Commit title (feat(scope): ... / fix(scope): ... / docs(scope): ... / chore(scope): ...).
  • Crate changelog updated (if the public API is affected).
  • Spec coverage documentation updated (if specification behavior is affected).

Please let me know if the new public API needs a changelog entry. Spec coverage documentation is not applicable to this extension.

Use filesystem identities for include guards and cycle detection while
preserving resolved paths for diagnostics and dependency tracking.

Add regression tests for path aliases, distinct files, virtual loaders,
and platform-specific filesystem behavior.

Fixes zero-objects#65
@SandraK82

Copy link
Copy Markdown
Contributor

Thank you, this is in. I read it and ran it on Linux (zerodds-idl-parse, zerodds-idl-compose, zerodds-idl-lower, zerodds-ast, the affected zerodds-idlc and zerodds-build tests, clippy with -D warnings): green.

It is in our main repository with you as the author, unchanged except for the line endings of pragma_once_paths.rs (LF). I added the CHANGELOG entries (the fix, and FileLoader::identity under Added) and a zerodds-build test with the two cases of #65.

One thing before I merge it here: the rustfmt check fails with "Incorrect newline style" for crates/idl-compose/tests/pragma_once_paths.rs, which has CRLF line endings. Could you push it with LF? Then I merge this pull request, so the history of this repository carries your commit.

@MatthewS8

Copy link
Copy Markdown
Contributor Author

Thank you! I am sorry I missed that! It should be fixed now!

@SandraK82
SandraK82 merged commit 4cbea35 into zero-objects:main Nov 12, 2026
12 checks passed
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.

#pragma once does not prevent repeated includes through different relative paths

2 participants