fix(frontends/lean/structure_cmd): fixes #1681
@kha I'm not sure if this is the right fix. I just avoided the loop that adds
`mk_expr_placeholder` if the function is not a projection.
I didn't spend time investigating why we need `mk_proj_app`.
I know the library doesn't compile if we don't use it, and just use
```
return mk_app(copy_tag(ref, mk_constant(S_name + fname)), e);
```
:)
This commit is contained in:
parent
cfa34dc83e
commit
c7e68e57cf
2 changed files with 28 additions and 7 deletions
|
|
@ -179,14 +179,16 @@ void get_structure_fields_flattened(environment const & env, name const & struct
|
|||
|
||||
expr mk_proj_app(environment const & env, name const & S_name, name const & fname, expr const & e, expr const & ref) {
|
||||
if (is_structure_like(env, S_name)) {
|
||||
auto nparams = std::get<1>(get_structure_info(env, S_name));
|
||||
auto proj = mk_explicit(copy_tag(ref, mk_constant(S_name + fname)));
|
||||
for (unsigned i = 0; i < nparams; i++)
|
||||
proj = mk_app(proj, mk_expr_placeholder());
|
||||
return mk_app(proj, e);
|
||||
} else {
|
||||
return mk_app(copy_tag(ref, mk_constant(S_name + fname)), e);
|
||||
name proj_name = S_name + fname;
|
||||
if (get_projection_info(env, proj_name)) {
|
||||
auto proj = mk_explicit(copy_tag(ref, mk_constant(proj_name)));
|
||||
auto nparams = std::get<1>(get_structure_info(env, S_name));
|
||||
for (unsigned i = 0; i < nparams; i++)
|
||||
proj = mk_app(proj, mk_expr_placeholder());
|
||||
return mk_app(proj, e);
|
||||
}
|
||||
}
|
||||
return mk_app(copy_tag(ref, mk_constant(S_name + fname)), e);
|
||||
}
|
||||
|
||||
optional<expr> mk_base_projections(environment const & env, name const & S_name, name const & base_S_name, expr const & e) {
|
||||
|
|
|
|||
19
tests/lean/run/1681.lean
Normal file
19
tests/lean/run/1681.lean
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
def prod.foo (s : bool × bool) (fst : bool) : bool × bool :=
|
||||
match s with
|
||||
(a, b) := (fst, b)
|
||||
end
|
||||
|
||||
variable s : bool × bool
|
||||
|
||||
#check prod.foo s
|
||||
#check prod.foo s tt
|
||||
#check s.foo
|
||||
#check s.foo tt
|
||||
|
||||
def prod.foo2 {α β} (s : α × β) (fst : α) : α × β :=
|
||||
match s with
|
||||
(a, b) := (fst, b)
|
||||
end
|
||||
|
||||
#check s.foo2
|
||||
#check s.foo2 tt
|
||||
Loading…
Add table
Reference in a new issue