diff options
author | Adam Chlipala <adam@chlipala.net> | 2012-05-02 08:56:19 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2012-05-02 08:56:19 -0400 |
commit | 1fd7e4392db0bace167853850188c464b00a8126 (patch) | |
tree | 62439e548ac25411e953783beb116b5937e87fae | |
parent | b314c01095c5cd4617f71f706e43530a57ffb65b (diff) |
Don't modify the module cache after elaboration failures
-rw-r--r-- | src/elaborate.sml | 7 | ||||
-rw-r--r-- | src/mod_db.sig | 4 | ||||
-rw-r--r-- | src/mod_db.sml | 6 | ||||
-rw-r--r-- | tests/baddep.urp | 2 | ||||
-rw-r--r-- | tests/baddep1.ur | 1 | ||||
-rw-r--r-- | tests/baddep2.ur | 1 |
6 files changed, 21 insertions, 0 deletions
diff --git a/src/elaborate.sml b/src/elaborate.sml index 26ec21ec..41e9e9ab 100644 --- a/src/elaborate.sml +++ b/src/elaborate.sml @@ -4461,6 +4461,8 @@ fun resolveClass env = E.resolveClass (hnormCon env) (consEq env dummy) env fun elabFile basis basis_tm topStr topSgn top_tm env file = let + val () = ModDb.snapshot () + val () = mayDelay := true val () = delayedUnifs := [] val () = delayedExhaustives := [] @@ -4788,6 +4790,11 @@ fun elabFile basis basis_tm topStr topSgn top_tm env file = end else (); + + if ErrorMsg.anyErrors () then + ModDb.revert () + else + (); (L'.DFfiStr ("Basis", basis_n, sgn), ErrorMsg.dummySpan) :: ds diff --git a/src/mod_db.sig b/src/mod_db.sig index 2b98ae6f..8f78f2c2 100644 --- a/src/mod_db.sig +++ b/src/mod_db.sig @@ -35,4 +35,8 @@ signature MOD_DB = sig * We might invalidate other declarations that depend on this one, if the timestamp has changed. *) val lookup : Source.decl -> Elab.decl option + + (* Allow undoing to snapshots after failed compilations. *) + val snapshot : unit -> unit + val revert : unit -> unit end diff --git a/src/mod_db.sml b/src/mod_db.sml index 22c11183..5e9e3342 100644 --- a/src/mod_db.sml +++ b/src/mod_db.sml @@ -141,4 +141,10 @@ fun lookup (d : Source.decl) = NONE) | _ => NONE +val byNameBackup = ref (!byName) +val byIdBackup = ref (!byId) + +fun snapshot () = (byNameBackup := !byName; byIdBackup := !byId) +fun revert () = (byName := !byNameBackup; byId := !byIdBackup) + end diff --git a/tests/baddep.urp b/tests/baddep.urp new file mode 100644 index 00000000..0e65b25d --- /dev/null +++ b/tests/baddep.urp @@ -0,0 +1,2 @@ +baddep1 +baddep2 diff --git a/tests/baddep1.ur b/tests/baddep1.ur new file mode 100644 index 00000000..14573638 --- /dev/null +++ b/tests/baddep1.ur @@ -0,0 +1 @@ +val x : int = "hi" diff --git a/tests/baddep2.ur b/tests/baddep2.ur new file mode 100644 index 00000000..22c5e3ae --- /dev/null +++ b/tests/baddep2.ur @@ -0,0 +1 @@ +fun main () : transaction page = return <xml/> |