Closed weaversa closed 1 day ago
This program contains a type error, as it is applying inf
(of kind #
) to an argument, which isn't well formed. A valid version of this program would be:
f : {n} [n] -> [n+1]
f x
| (fin n) => x # [False]
| (n == inf) => x
I'm not yet clear on why Cryptol panics on the invalid inf n
constraint instead of emitting an ordinary type error. Note that inf
isn't essential to triggering the panic, as the following program also panics:
f : {n} [n] -> [n+1]
f x
| (fin n) => x # [False]
| (n) => x
Some investigation reveals that this is really the same issue as was reported in https://github.com/GaloisInc/cryptol/issues/1593, except that in this example, a guard contains a type error rather than a invalid (but otherwise well-typed) constraint. The fix proposed in https://github.com/GaloisInc/cryptol/issues/1593#issuecomment-1936031295 also fixes this issue, although I'm unclear if that is the right way to go about fixing this issue. (@yav, I'd be interested to hear your thoughts on this.)
@RyanGlScott aborting if there are errors seems reasonable to me. I guess we could also add a haveErrors :: InferM Bool
function and just skip the exhaustiveness checking instead of aborting entirely, but I am not sure if it is needed.
In case you didn't notice, it may be worthwhile to change "Unexpeceted" -> "Unexpected".
Ah, quite right. I've added a separate commit to #1695 that fixes this typo.
I'm feeling like this should work.
For context, I was trying to define Keccak's
b2h
function. Conceptually, it should work on both finite and infinite sequences.vs. (roughly)