Two checker errors name a value that is not the cause. The rules behind them are clear, and the guide documents both. Only the messages are wrong.
1. The + marker on a Type parameter
A + marker makes a value reusable. The guide says that this marker needs a Data value, and that functions, arrays and IO handles are Type. So the checker refuses + on those values. That refusal is correct.
The message does not say this. It reports expected : Data / observed : Type. It never mentions the marker, the copy, or the parameter. When the def has more than one parameter, the Context block names a different parameter. That parameter is correct.
import Base
def two(+name: String, +res: Result<&1, &1, U32 & String, Unit>) -> Unit:
Unit{}
Output:
Error:
- expected : Data
- observed : Type
Context:
- name : String
Location: two
3>| def two(+name: String, +res: Result<&1, &1, U32 & String, Unit>) -> Unit:
The offender is res. The Context block names name.
With one parameter, the same error gives no Context block at all:
import Base
def hold(+h: File) -> Unit:
Unit{}
Error:
- expected : Data
- observed : Type
Location: hold
2. A double use inside a 1n+f pattern
This def matches n, then uses n again in the body. That is two uses of n, and n is affine. The checker refuses it.
The message names f instead. f occurs one time, in the recursive call.
import Base
def count(n: Nat, acc: Nat) -> Nat:
match n
case 0n:
acc
case 1n+f:
count(f, (n + acc : Nat))
Output:
Error:
- expected : f
- observed : f (consumed more than once)
Location: count
7>| case 1n+f:
8 | count(f, (n + acc : Nat))
The line numbers are correct. The name is not.
What would help
- Name the value that breaks the rule. For the
+ case, that is the marked parameter. For the pattern case, that is the value used two times.
- State the rule in the message. For the
+ case, a sentence such as "+ needs a Data value; this type is Type" would remove the guesswork.
Version
bend 2.0.25 (installed with `bend update`)
bun 1.3.14, Darwin arm64
Related: #957, #964, #965 -- the three bugs this project works around.
The reproducers were run by me with an AI assistant.
Two checker errors name a value that is not the cause. The rules behind them are clear, and the guide documents both. Only the messages are wrong.
1. The
+marker on aTypeparameterA
+marker makes a value reusable. The guide says that this marker needs aDatavalue, and that functions, arrays and IO handles areType. So the checker refuses+on those values. That refusal is correct.The message does not say this. It reports
expected : Data / observed : Type. It never mentions the marker, the copy, or the parameter. When the def has more than one parameter, theContextblock names a different parameter. That parameter is correct.Output:
The offender is
res. TheContextblock namesname.With one parameter, the same error gives no
Contextblock at all:2. A double use inside a
1n+fpatternThis def matches
n, then usesnagain in the body. That is two uses ofn, andnis affine. The checker refuses it.The message names
finstead.foccurs one time, in the recursive call.Output:
The line numbers are correct. The name is not.
What would help
+case, that is the marked parameter. For the pattern case, that is the value used two times.+case, a sentence such as "+needs a Data value; this type is Type" would remove the guesswork.Version
Related: #957, #964, #965 -- the three bugs this project works around.
The reproducers were run by me with an AI assistant.