fix(frontends/lean/parser): user provided numeral notation should have precedence over the default based on 'num'
This commit is contained in:
parent
bc65aeb5e1
commit
2487e3b83d
2 changed files with 17 additions and 2 deletions
|
@ -1167,10 +1167,12 @@ expr parser::parse_numeral_expr() {
|
|||
"(solution: use 'import data.num', or define notation for the given numeral)", p);
|
||||
}
|
||||
buffer<expr> cs;
|
||||
for (expr const & c : vals)
|
||||
cs.push_back(copy_with_new_pos(c, p));
|
||||
if (*m_has_num)
|
||||
cs.push_back(save_pos(from_num(n), p));
|
||||
for (expr const & c : vals)
|
||||
cs.push_back(copy_with_new_pos(c, p));
|
||||
// Remark: choices are processed from right to left.
|
||||
// We want to process user provided notation before the default 'num'.
|
||||
lean_assert(!cs.empty());
|
||||
if (cs.size() == 1)
|
||||
return cs[0];
|
||||
|
|
13
tests/lean/run/num_bug2.lean
Normal file
13
tests/lean/run/num_bug2.lean
Normal file
|
@ -0,0 +1,13 @@
|
|||
import algebra.ring data.num
|
||||
open algebra
|
||||
|
||||
variable A : Type
|
||||
variable s : ring A
|
||||
variable H0 : 0 = 0 -- since algebra defines notation '0' it should have precedence over num
|
||||
variable H1 : 1 = 1 -- since algebra defines notation '1' it should have precedence over num
|
||||
|
||||
example : has_zero.zero A = has_zero.zero A :=
|
||||
H0
|
||||
|
||||
example : has_one.one A = has_one.one A :=
|
||||
H1
|
Loading…
Reference in a new issue