fix: projection of string literals
This commit is contained in:
parent
5fcd08326f
commit
4675817a9e
3 changed files with 8 additions and 0 deletions
|
|
@ -294,6 +294,7 @@ def reduceMatcher? (e : Expr) : MetaM ReduceMatcherResult := do
|
|||
/- Given an expression `e`, compute its WHNF and if the result is a constructor, return field #i. -/
|
||||
def project? (e : Expr) (i : Nat) : MetaM (Option Expr) := do
|
||||
let e ← whnf e
|
||||
let e := toCtorIfLit e
|
||||
matchConstCtor e.getAppFn (fun _ => pure none) fun ctorVal _ =>
|
||||
let numArgs := e.getAppNumArgs
|
||||
let idx := ctorVal.numParams + i
|
||||
|
|
|
|||
|
|
@ -366,6 +366,8 @@ optional<expr> type_checker::reduce_proj(expr const & e, bool cheap) {
|
|||
c = whnf_core(proj_expr(e), cheap);
|
||||
else
|
||||
c = whnf(proj_expr(e));
|
||||
if (is_string_lit(c))
|
||||
c = string_lit_to_constructor(c);
|
||||
buffer<expr> args;
|
||||
expr const & mk = get_app_args(c, args);
|
||||
if (!is_constant(mk))
|
||||
|
|
|
|||
5
tests/lean/run/strLitProj.lean
Normal file
5
tests/lean/run/strLitProj.lean
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#reduce "".data
|
||||
|
||||
example : "".data = [] := rfl
|
||||
|
||||
theorem ex : "".data = [] := rfl
|
||||
Loading…
Add table
Reference in a new issue