Open isovector opened 2 years ago
Well, x
is part of a mixfix constructor, so it cannot be used as a pattern variable here. But I agree there is something off here, because Agda claims:
Operators used in the grammar:
None
Maybe I expect to see:
Operators used in the grammar:
var_x (closed operator)
This is what you get if you also include var
on the lhs, e.g.:
bug : Bug → Bug
var bug x = {! !}
The grammar only includes operators for which, roughly speaking, all name parts are present in the expression/pattern that is parsed.
The grammar only includes operators for which, roughly speaking, all name parts are present in the expression/pattern that is parsed.
But if this is the case, what is the reason that parsing would fail?
I actually hadn't noticed that my variable name x
was part of the mixfix var_x
, which makes this behavior more scrutable. However, I think a better error message here would go a very long way!
But if this is the case, what is the reason that parsing would fail?
In this case var
and x
are part of conParts
(because x
is mentioned in the pattern), but not conNames
. Perhaps the error message could include an explanation of which things are allowed as "atoms".
Perhaps the error message could include an explanation of which things are allowed as "atoms".
Yes, please. Should be easy since all the information is on the table already.
One other confounding issue here is that make case and refinement were both automatically choosing the name x
for my variable in bug
.
automatically choosing the name
x
for my variable inbug
.
x
is the default if no other name is suggested. You can give a name to the argument of bug
, and then this one will be used:
bug : (philosantos : Bug) -> Bug
The default chosen name for the first argument of bug
is then philosantos
.
Unfortunately, if that chosen name isn't valid as pattern variable, then Agda doesn't try another one, but errors out, as you report. Agda doesn't maintain a set of names that mustn't be shadowed by a pattern variable, unfortunately. Those are the names of constructors that are in scope or could easily come into scope, or (apparently), parts of those.
produces the error message
Removing
x
, and then attempting to refine the hole instead gives this error: