Diagnostic and cause
LinkInvalid exported let pattern
- Family
- topaz
- Phase
- parse
- Code
TPZ2007
Cause and conditions
An exported let uses the ordinary immutable let pattern rules and publishes every bound name. A pattern with no bound name is rejected with TPZ2007 during parsing.
Related rule: Trigger and repairResponse
Remove export when no name is published, or bind the names that callers need with an ordinary immutable let pattern.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 274-282 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 1216-1216 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 1206-1224 - compiler/crates/topaz_self_frontend/topaz/parser/types_patterns.tpz at
151141d7bb44· 510-533 - TPZ2007 at
151141d7bb44
The 6.0 contract rejects exported patterns without a bound name. The following message and observation describe the historical 5.21.3 single-identifier restriction. They do not prohibit destructuring in Topaz 6.0.
Compiler phase: parse.
Compiler explanation: An exported let declaration uses a pattern other than one identifier.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
- an exported
letbinds exactly one identifier; destructure privately, then export the identifier Source
An exported let pattern binds no name. Use export for one or more ordinary immutable pattern bindings.
Trigger and repair
An exported let uses the ordinary immutable let pattern rules and publishes every bound name. A pattern with no bound name is rejected with TPZ2007 during parsing.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 1206-1224 - compiler/crates/topaz_self_frontend/topaz/parser/types_patterns.tpz at
151141d7bb44· 510-533 - TPZ2007 at
151141d7bb44
Response
LinkRemove export when no name is published, or bind the names that callers need with an ordinary immutable let pattern.
Reproduction and verification
LinkRejected program
Linkexport let _ = 1
No stdout.
Expected result
Expected result
Rejection during parse. Nonzero exit.
TPZ2007export-let-no-binding atexample.tpz:1:12
The expected diagnostic, cause, source location, and accompanying diagnostics are specified below. The verification status records whether this program has been run.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 274-282 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 1216-1216 - compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 1206-1224 - compiler/crates/topaz_self_frontend/topaz/parser/types_patterns.tpz at
151141d7bb44· 510-533 - TPZ2007 at
151141d7bb44
Corrected program
Linklet _ = 1
Expected result
Expected result
Checking accepts the program. Exit code 0.
This program applies the repair described above. The verification status records whether it has been run.
Source evidence
- compiler/crates/topaz_self_frontend/topaz/parser/declarations_modules.tpz at
151141d7bb44· 1206-1224 - compiler/crates/topaz_self_frontend/topaz/parser/types_patterns.tpz at
151141d7bb44· 510-533 - TPZ2007 at
151141d7bb44