fix(frontends/lean/scanner): another bug related to issue #626

This commit is contained in:
Leonardo de Moura 2015-05-26 13:39:42 -07:00
parent ed01242bc1
commit 0502f46f9b
3 changed files with 111 additions and 28 deletions

View file

@ -348,40 +348,39 @@ auto scanner::read_key_cmd_id() -> token_kind {
} }
} }
} }
unsigned i = 0; unsigned i = 0;
token_table const * it = find(*m_tokens, cs[i]); token_table const * it = m_tokens;
token_info const * info = nullptr; token_info const * info = nullptr;
unsigned key_sz = 0; unsigned key_sz = 0;
unsigned key_utf_sz = 0; unsigned key_utf_sz = 0;
unsigned aux_num_utfs = id_utf_sz; while (i < id_sz) {
if (it) { it = find(*it, cs[i]);
if (aux_num_utfs == 0) i++;
aux_num_utfs = 1; if (!it)
info = value_of(*it); break;
if (info) { if (auto new_info = value_of(*it)) {
lean_assert(m_uskip == 0); lean_assert(m_uskip == 0);
key_sz = 1; info = new_info;
key_utf_sz = aux_num_utfs; key_sz = i;
key_utf_sz = id_utf_sz; // this is imprecise if key_sz < id_sz, but this case is irrelevant
} }
while (it) { }
i++;
if (i == cs.size()) { while (it) {
next_utf(cs); if (i == cs.size()) {
num_utfs++; next_utf(cs);
aux_num_utfs = num_utfs; num_utfs++;
} }
it = find(*it, cs[i]); it = find(*it, cs[i]);
if (it) { i++;
if (auto new_info = value_of(*it)) { if (!it)
lean_assert(m_uskip == 0); break;
info = new_info; if (auto new_info = value_of(*it)) {
key_sz = i+1; lean_assert(m_uskip == 0);
key_utf_sz = aux_num_utfs; info = new_info;
} key_sz = i;
} else { key_utf_sz = num_utfs;
break; lean_assert(key_sz > id_sz);
}
} }
} }

14
tests/lean/626c.lean Normal file
View file

@ -0,0 +1,14 @@
notation `C⁽` := nat
definition foo (c : C⁽) := nat.rec_on c _ _
notation `α⁽` := nat
definition foo (c : α⁽) := nat.rec_on c _ _
notation `_⁽` := nat
definition foo (c : _⁽) := nat.rec_on c _ _
notation `C.⁽` := nat
definition foo (c : C.⁽) := nat.rec_on c _ _
notation `C⁽C⁽` := nat
definition foo (c : C⁽C⁽) := nat.rec_on c _ _

View file

@ -0,0 +1,70 @@
626c.lean:2:27: error: don't know how to synthesize placeholder
c : C⁽
⊢ C⁽ → Type
626c.lean:2:40: error: don't know how to synthesize placeholder
c : C⁽
⊢ ?M_1
626c.lean:2:42: error: don't know how to synthesize placeholder
c : C⁽
⊢ Π (a : C⁽),
?M_1 → ?M_1
626c.lean:2:27: error: failed to add declaration 'foo' to environment, value has metavariables
remark: set 'formatter.hide_full_terms' to false to see the complete term
λ (c : C⁽),
nat.rec_on c ?M_2 ?M_3
626c.lean:5:27: error: don't know how to synthesize placeholder
c : α⁽
⊢ α⁽ → Type
626c.lean:5:40: error: don't know how to synthesize placeholder
c : α⁽
⊢ ?M_1
626c.lean:5:42: error: don't know how to synthesize placeholder
c : α⁽
⊢ Π (a : α⁽),
?M_1 → ?M_1
626c.lean:5:27: error: failed to add declaration 'foo' to environment, value has metavariables
remark: set 'formatter.hide_full_terms' to false to see the complete term
λ (c : α⁽),
nat.rec_on c ?M_2 ?M_3
626c.lean:8:27: error: don't know how to synthesize placeholder
c : _⁽
⊢ _⁽ → Type
626c.lean:8:40: error: don't know how to synthesize placeholder
c : _⁽
⊢ ?M_1
626c.lean:8:42: error: don't know how to synthesize placeholder
c : _⁽
⊢ Π (a : _⁽),
?M_1 → ?M_1
626c.lean:8:27: error: failed to add declaration 'foo' to environment, value has metavariables
remark: set 'formatter.hide_full_terms' to false to see the complete term
λ (c : _⁽),
nat.rec_on c ?M_2 ?M_3
626c.lean:11:28: error: don't know how to synthesize placeholder
c : C.⁽
⊢ C.⁽ → Type
626c.lean:11:41: error: don't know how to synthesize placeholder
c : C.⁽
⊢ ?M_1
626c.lean:11:43: error: don't know how to synthesize placeholder
c : C.⁽
⊢ Π (a : C.⁽),
?M_1 → ?M_1
626c.lean:11:28: error: failed to add declaration 'foo' to environment, value has metavariables
remark: set 'formatter.hide_full_terms' to false to see the complete term
λ (c : C.⁽),
nat.rec_on c ?M_2 ?M_3
626c.lean:14:29: error: don't know how to synthesize placeholder
c : C⁽C⁽
⊢ C⁽C⁽ → Type
626c.lean:14:42: error: don't know how to synthesize placeholder
c : C⁽C⁽
⊢ ?M_1
626c.lean:14:44: error: don't know how to synthesize placeholder
c : C⁽C⁽
⊢ Π (a : C⁽C⁽),
?M_1 → ?M_1
626c.lean:14:29: error: failed to add declaration 'foo' to environment, value has metavariables
remark: set 'formatter.hide_full_terms' to false to see the complete term
λ (c : C⁽C⁽),
nat.rec_on c ?M_2 ?M_3