mirror of
https://github.com/anoma/juvix.git
synced 2024-12-14 08:27:03 +03:00
df4187a25f
Closes #1483 The error now points to the offending `=`, works correctly with multi-line clauses, and explains exactly what's wrong. E.g. for ```agda f : Nat → Nat → Nat; f zero x = x; ``` we get ``` | 6 | f zero x = x; | ^ expected ":=" instead of "=" ``` A minor disadvantage of the proposed solution is that now it's impossible to use `=` without parentheses as a top variable name in a pattern, e.g. ``` f zero = := =; ``` gives an error. However, if one really wants to name a variable `=`, it is enough just to enclose it in parentheses: ```agda f : Nat → Nat → Nat; f zero (=) := =; f (suc n) (=) := f n =; ``` I believe this slight non-uniformity is well worth the increased usability due to a better error message. Confusing `:=` with `=` is very common. Using `=` as a variable name in a top pattern is rare. Co-authored-by: janmasrovira <janmasrovira@gmail.com>
37 lines
590 B
Plaintext
37 lines
590 B
Plaintext
module Symbols;
|
||
open import Stdlib.Data.Nat;
|
||
|
||
╘⑽╛ : Nat;
|
||
╘⑽╛ := suc nine;
|
||
|
||
-- no - function!?
|
||
- : Nat -> Nat -> Nat;
|
||
- := (+);
|
||
|
||
(-) : Nat -> Nat -> Nat;
|
||
(-) := (-);
|
||
|
||
(*) : Nat -> Nat -> Nat;
|
||
(*) := (*);
|
||
|
||
infixl 6 -;
|
||
- : Nat -> Nat -> Nat;
|
||
- := (-);
|
||
|
||
infixl 7 ·;
|
||
· : Nat -> Nat -> Nat;
|
||
· := (*);
|
||
|
||
(0) : Nat;
|
||
(0) := ╘⑽╛ - ╘⑽╛ · zero;
|
||
|
||
主功能 : Nat;
|
||
主功能 := (0);
|
||
|
||
axiom = : Type;
|
||
|
||
K : Nat → Nat → Nat;
|
||
K =a@zero (=) := =a · =;
|
||
K =a@(suc =) == := = · ==;
|
||
end;
|