diff --git a/Pantograph/Protocol.lean b/Pantograph/Protocol.lean index d80c761..f232d9e 100644 --- a/Pantograph/Protocol.lean +++ b/Pantograph/Protocol.lean @@ -327,14 +327,16 @@ structure InvokedTactic where structure CompilationUnit where -- String boundaries of compilation units boundary: (Nat × Nat) + messages: Array String := #[] -- Tactic invocations invocations?: Option (List InvokedTactic) := .none goalStateId?: Option Nat := .none - goals: Array Goal := #[] + goals?: Option (Array Goal) := .none -- Code segments which generated the goals - goalSrcBoundaries: Array (Nat × Nat) := #[] - messages: Array String := #[] - newConstants: Option (Array String) := .none + goalSrcBoundaries?: Option (Array (Nat × Nat)) := .none + + -- New constants defined in compilation unit + newConstants?: Option (Array String) := .none deriving Lean.ToJson structure FrontendProcessResult where units: List CompilationUnit diff --git a/Repl.lean b/Repl.lean index 710b132..283bcf3 100644 --- a/Repl.lean +++ b/Repl.lean @@ -269,25 +269,26 @@ def execute (command: Protocol.Command): MainM Lean.Json := do return (step.before, boundary, invocations?, sorrys, messages, newConstants) let li ← frontendM.run context |>.run' state let units ← li.mapM λ (env, boundary, invocations?, sorrys, messages, newConstants) => Lean.withEnv env do - let newConstants := if args.newConstants then + let newConstants? := if args.newConstants then .some $ newConstants.toArray.map λ name => name.toString else .none - let (goalStateId?, goals, goalSrcBoundaries) ← if sorrys.isEmpty then do - pure (.none, #[], #[]) + let (goalStateId?, goals?, goalSrcBoundaries?) ← if sorrys.isEmpty then do + pure (.none, .none, .none) else do let { state, srcBoundaries } ← runMetaInMainM $ Frontend.sorrysToGoalState sorrys let stateId ← newGoalState state let goals ← goalSerialize state options - pure (.some stateId, goals, srcBoundaries.toArray.map (λ (b, e) => (b.byteIdx, e.byteIdx))) + let srcBoundaries := srcBoundaries.toArray.map (λ (b, e) => (b.byteIdx, e.byteIdx)) + pure (.some stateId, .some goals, .some srcBoundaries) return { boundary, + messages, invocations?, goalStateId?, - goals, - goalSrcBoundaries, - messages, - newConstants, + goals?, + goalSrcBoundaries?, + newConstants?, } return .ok { units } catch e => diff --git a/Test/Integration.lean b/Test/Integration.lean index 8d53168..3e9bed2 100644 --- a/Test/Integration.lean +++ b/Test/Integration.lean @@ -223,8 +223,8 @@ def test_frontend_process_sorry : Test := }, { boundary := (solved.utf8ByteSize, solved.utf8ByteSize + withSorry.utf8ByteSize), goalStateId? := .some 0, - goals := #[goal1], - goalSrcBoundaries := #[(57, 62)], + goals? := .some #[goal1], + goalSrcBoundaries? := .some #[(57, 62)], messages := #[":2:0: warning: declaration uses 'sorry'\n"], }], }: Protocol.FrontendProcessResult),