@@ -1340,7 +1340,7 @@ private def resolveLValAux (e : Expr) (eType : Expr) (lval : LVal) : TermElabM L
13401340 throwErrorAt ref m!"{msg}{.nil}"
13411341 if eType.isForall then
13421342 match lval with
1343- | LVal.fieldName _ fieldName suffix? fullRef =>
1343+ | LVal.fieldName ref fieldName suffix? _fullRef =>
13441344 let fullName := Name.str `Function fieldName
13451345 if (← getEnv).contains fullName then
13461346 return LValResolution.const `Function `Function fullName
@@ -1349,7 +1349,7 @@ private def resolveLValAux (e : Expr) (eType : Expr) (lval : LVal) : TermElabM L
13491349 been a field in the `Function` namespace, so we needn't wait to check if this is actually
13501350 a constant. If `suffix?` is non-`none`, we prefer to throw the "unknown constant" error
13511351 (because of monad namespaces like `IO` and auxiliary declarations like `mutual_induct`) -/
1352- throwInvalidFieldAt fullRef fieldName fullName
1352+ throwInvalidFieldAt ref fieldName fullName
13531353 | .fieldIdx .. =>
13541354 throwLValError e eType "Invalid projection: Projections cannot be used on functions"
13551355 else if eType.getAppFn.isMVar then
@@ -1386,7 +1386,7 @@ private def resolveLValAux (e : Expr) (eType : Expr) (lval : LVal) : TermElabM L
13861386 throwError m!"Invalid projection: Index `{idx}` is invalid for this structure; {bounds}"
13871387 ++ .note m!"The expression{inlineExpr e}has type{inlineExpr eType}which has only {numFields} {fields}"
13881388 ++ tupleHint
1389- | some structName, LVal.fieldName _ fieldName _ fullRef =>
1389+ | some structName, LVal.fieldName ref fieldName _ _ => withRef ref do
13901390 let env ← getEnv
13911391 if isStructure env structName then
13921392 if let some baseStructName := findField? env structName (Name.mkSimple fieldName) then
@@ -1402,15 +1402,15 @@ private def resolveLValAux (e : Expr) (eType : Expr) (lval : LVal) : TermElabM L
14021402 -- Then search the environment
14031403 if let some (baseStructName, fullName) ← findMethod? structName (.mkSimple fieldName) then
14041404 return LValResolution.const baseStructName structName fullName
1405- throwInvalidFieldAt fullRef fieldName fullName
1405+ throwInvalidFieldAt ref fieldName fullName
14061406 -- Suggest a potential unreachable private name as hint. This does not cover structure
14071407 -- inheritance, nor `import all`.
14081408 (declHint := (mkPrivateName env structName).mkStr fieldName)
1409- | none, LVal.fieldName _ _ (some suffix) fullRef =>
1409+ | none, LVal.fieldName ref _ (some suffix) _fullRef =>
14101410 -- This may be a function constant whose implicit arguments have already been filled in:
14111411 let c := e.getAppFn
14121412 if c.isConst then
1413- throwUnknownConstantAt fullRef (c.constName! ++ suffix)
1413+ throwUnknownConstantAt ref (c.constName! ++ suffix)
14141414 else
14151415 throwInvalidFieldNotation e eType
14161416 | _, _ => throwInvalidFieldNotation e eType
@@ -1619,7 +1619,7 @@ private def elabAppLValsAux (namedArgs : Array NamedArg) (args : Array Arg) (exp
16191619 let some info := getFieldInfo? (← getEnv) baseStructName fieldName | unreachable!
16201620 if (← isInaccessiblePrivateName info.projFn) then
16211621 throwError "Field `{fieldName}` from structure `{structName}` is private"
1622- let projFn ← mkConst info.projFn
1622+ let projFn ← withRef lval.getRef <| mkConst info.projFn
16231623 let projFn ← addProjTermInfo lval.getRef projFn
16241624 if lvals.isEmpty then
16251625 let namedArgs ← addNamedArg namedArgs { name := `self, val := Arg.expr f, suppressDeps := true }
@@ -1629,7 +1629,7 @@ private def elabAppLValsAux (namedArgs : Array NamedArg) (args : Array Arg) (exp
16291629 loop f lvals
16301630 | LValResolution.const baseStructName structName constName =>
16311631 let f ← if baseStructName != structName then mkBaseProjections baseStructName structName f else pure f
1632- let projFn ← mkConst constName
1632+ let projFn ← withRef lval.getRef <| mkConst constName
16331633 let projFn ← addProjTermInfo lval.getRef projFn
16341634 if lvals.isEmpty then
16351635 let (args, namedArgs) ← addLValArg baseStructName f args namedArgs projFn explicit
0 commit comments