Type: bare 'Quotation' in signatures is silently treated as type variable, not quotation type #266
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq#266
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Writing
Quotationin a type signature is silently parsed as a type variable (Type::Var("Quotation")), not as an actual quotation type. This leads to confusing behavior whereQuotationunifies with any type.Example
Here
Quotationlooks like it means "a quotation type" but is actually treated as a generic type variable (likeTorFoo). It will unify withInt,String, or anything else.Root Cause
In
crates/compiler/src/parser.rs,parse_type()treats any uppercase identifier as a type variable:There's no special handling for
Quotationas a reserved type name.The Design Problem
The type system has
Type::Quotation(Box<Effect>)which always requires an explicit effect. There's no way to express "any quotation" without specifying its stack effect. This creates a gap where users naturally writeQuotationexpecting it to mean "some quotation" but it means something completely different.Proposed Solutions
Option A: Make
Quotationa reserved type meaning[ ..rest -- ..rest ]This would mean "any quotation that preserves the stack" - essentially polymorphic over effect. Simple but may be too restrictive.
Option B: Reject
Quotationas a type variable with a helpful errorThis forces users to be explicit about the expected effect.
Option C: Add proper existential quantification for quotation effects
Allow something like
[ ..? -- ..? ]meaning "some unknown effect" that gets inferred. More complex but more powerful.Recommendation
Option B (reject with error) is the safest short-term fix. It prevents silent misuse and guides users to the correct syntax. Option C could be considered for future enhancement.
After discussion: Option C (existential quantification) is unnecessary. Without generics, an "any effect" quotation type would be useless - you couldn't propagate the unknown effect through type signatures, so you couldn't safely call the quotation.
The fix is simply Option B: reject
Quotationas a type variable name with a helpful error message pointing to the explicit[... -- ...]syntax.If you're accepting a quotation, you need to know its effect to use it.
https://github.com/navicore/patch-seq/pull/267