Accept qualified contract names in fulfils/demands clauses (#21)#33
Merged
Conversation
parse_contracts_clause parsed a single bare ident for the contract name, so `fulfils base/MyContract` failed with "expected block item ..., found '/'" — while the language reference says contracts are importable across modules via `use`, following the same coordinate system as entity imports, and `base/Caller` already parses in facing position. The contracts clause now accepts `alias/Name`, stored as a new `qualifier: Option<String>` on ContractBinding (mirroring QualifiedName). Unlike expression position there is no division to disambiguate from, so the `/` is consumed unconditionally. Analysis keeps in step: qualified entries are collected as cross-module qualified references (so the imported contract counts as used in its defining module), and no longer pollute the local referenced-idents set, where they could mask an unused same-named local Value or Enum. The WASM/TS mirror type WasmContractBinding gains the qualifier field. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #21.
Problem
parse_contracts_clauseparsed a single bare ident for the contract name, sofulfils base/MyContractfailed withexpected block item ..., found '/'— whilebase/Callerparses fine infacingposition, and the language reference (§ contract imports) says:So cross-spec contract sharing (one abstract contract, multiple
fulfilsproviders) was impossible without redeclaring the contract per spec — copies that drift silently, as the issue notes.Fix
alias/Nameafterdemands/fulfils. Unlike expression position there is no division to disambiguate from, so a/here can only introduce a qualified name and is consumed unconditionally. A missing name after/gets a targeted error (expected contract name after '/').ContractBindinggainsqualifier: Option<String>, mirroringQualifiedName.collect_qualified_references, so the imported contract counts as referenced in its defining module (cross-module unused tracking); they no longer insert their bare name into the local referenced-idents set, where a qualified ref could mask an unused same-named local Value/Enum.WasmContractBindinggains thequalifier: string | nullfield. Since the TS extension/LSP parse through this same WASM parser, the fix also removes theallium.parse.errorthe extension surfaced on these files (post-TypeScript analyzer discards WASM parse diagnostics #25).Verification
The issue's exact two-file reproducer now checks clean: exit 0, no parse error, and
MyContractis not flagged unused inbase.allium.Tests: 3 new parser unit tests (qualified fulfils, qualified+local mix, missing-name error), 1 CLI integration test with the issue's reproducer, 1 TS test that the qualified form parses with zero diagnostics. Full matrix green: Rust workspace (345 parser + 24 CLI integration + the rest), TS 314 extension + 8 LSP,
npm run lintclean.🤖 Generated with Claude Code