Compare commits

..

No commits in common. "1527743900b2af65514be9cf6a3d9f18b818874a" and "9a69c48cb23f313e5986e87a8867eaf3d9b6528e" have entirely different histories.

3 changed files with 13 additions and 30 deletions

View File

@ -312,8 +312,6 @@ structure FrontendProcess where
invocations: Bool := false invocations: Bool := false
-- If set to true, collect `sorry`s -- If set to true, collect `sorry`s
sorrys: Bool := false sorrys: Bool := false
-- If set to true, extract new constants
newConstants: Bool := false
deriving Lean.FromJson deriving Lean.FromJson
structure InvokedTactic where structure InvokedTactic where
goalBefore: String goalBefore: String
@ -327,16 +325,13 @@ structure InvokedTactic where
structure CompilationUnit where structure CompilationUnit where
-- String boundaries of compilation units -- String boundaries of compilation units
boundary: (Nat × Nat) boundary: (Nat × Nat)
messages: Array String := #[]
-- Tactic invocations -- Tactic invocations
invocations?: Option (List InvokedTactic) := .none invocations?: Option (List InvokedTactic) := .none
goalStateId?: Option Nat := .none goalStateId?: Option Nat := .none
goals?: Option (Array Goal) := .none goals: Array Goal := #[]
-- Code segments which generated the goals -- Code segments which generated the goals
goalSrcBoundaries?: Option (Array (Nat × Nat)) := .none goalSrcBoundaries: Array (Nat × Nat) := #[]
messages: Array String := #[]
-- New constants defined in compilation unit
newConstants?: Option (Array String) := .none
deriving Lean.ToJson deriving Lean.ToJson
structure FrontendProcessResult where structure FrontendProcessResult where
units: List CompilationUnit units: List CompilationUnit

View File

@ -262,33 +262,23 @@ def execute (command: Protocol.Command): MainM Lean.Json := do
else else
pure [] pure []
let messages ← step.messageStrings let messages ← step.messageStrings
let newConstants ← if args.newConstants then return (step.before, boundary, invocations?, sorrys, messages)
Frontend.collectNewDefinedConstants step
else
pure []
return (step.before, boundary, invocations?, sorrys, messages, newConstants)
let li ← frontendM.run context |>.run' state let li ← frontendM.run context |>.run' state
let units ← li.mapM λ (env, boundary, invocations?, sorrys, messages, newConstants) => Lean.withEnv env do let units ← li.mapM λ (env, boundary, invocations?, sorrys, messages) => Lean.withEnv env do
let newConstants? := if args.newConstants then let (goalStateId?, goals, goalSrcBoundaries) ← if sorrys.isEmpty then do
.some $ newConstants.toArray.map λ name => name.toString pure (.none, #[], #[])
else
.none
let (goalStateId?, goals?, goalSrcBoundaries?) ← if sorrys.isEmpty then do
pure (.none, .none, .none)
else do else do
let { state, srcBoundaries } ← runMetaInMainM $ Frontend.sorrysToGoalState sorrys let { state, srcBoundaries } ← runMetaInMainM $ Frontend.sorrysToGoalState sorrys
let stateId ← newGoalState state let stateId ← newGoalState state
let goals ← goalSerialize state options let goals ← goalSerialize state options
let srcBoundaries := srcBoundaries.toArray.map (λ (b, e) => (b.byteIdx, e.byteIdx)) pure (.some stateId, goals, srcBoundaries.toArray.map (λ (b, e) => (b.byteIdx, e.byteIdx)))
pure (.some stateId, .some goals, .some srcBoundaries)
return { return {
boundary, boundary,
messages,
invocations?, invocations?,
goalStateId?, goalStateId?,
goals?, goals,
goalSrcBoundaries?, goalSrcBoundaries,
newConstants?, messages,
} }
return .ok { units } return .ok { units }
catch e => catch e =>

View File

@ -174,7 +174,6 @@ def test_frontend_process : Test :=
("file", .str file), ("file", .str file),
("invocations", .bool true), ("invocations", .bool true),
("sorrys", .bool false), ("sorrys", .bool false),
("newConstants", .bool false),
] ]
({ ({
units := [{ units := [{
@ -215,7 +214,6 @@ def test_frontend_process_sorry : Test :=
("file", .str file), ("file", .str file),
("invocations", .bool false), ("invocations", .bool false),
("sorrys", .bool true), ("sorrys", .bool true),
("newConstants", .bool false),
] ]
({ ({
units := [{ units := [{
@ -223,8 +221,8 @@ def test_frontend_process_sorry : Test :=
}, { }, {
boundary := (solved.utf8ByteSize, solved.utf8ByteSize + withSorry.utf8ByteSize), boundary := (solved.utf8ByteSize, solved.utf8ByteSize + withSorry.utf8ByteSize),
goalStateId? := .some 0, goalStateId? := .some 0,
goals? := .some #[goal1], goals := #[goal1],
goalSrcBoundaries? := .some #[(57, 62)], goalSrcBoundaries := #[(57, 62)],
messages := #["<anonymous>:2:0: warning: declaration uses 'sorry'\n"], messages := #["<anonymous>:2:0: warning: declaration uses 'sorry'\n"],
}], }],
}: Protocol.FrontendProcessResult), }: Protocol.FrontendProcessResult),