# HG changeset patch # User Adam Chlipala # Date 1335963379 14400 # Node ID 78d7cc9c9b185492574c1916bf548b353af15c08 # Parent 7ec8dab190a78680f4060734d9d38f9cb1998065 Don't modify the module cache after elaboration failures diff -r 7ec8dab190a7 -r 78d7cc9c9b18 src/elaborate.sml --- a/src/elaborate.sml Wed May 02 08:34:50 2012 -0400 +++ b/src/elaborate.sml Wed May 02 08:56:19 2012 -0400 @@ -4461,6 +4461,8 @@ 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 @@ end else (); + + if ErrorMsg.anyErrors () then + ModDb.revert () + else + (); (L'.DFfiStr ("Basis", basis_n, sgn), ErrorMsg.dummySpan) :: ds diff -r 7ec8dab190a7 -r 78d7cc9c9b18 src/mod_db.sig --- a/src/mod_db.sig Wed May 02 08:34:50 2012 -0400 +++ b/src/mod_db.sig Wed May 02 08:56:19 2012 -0400 @@ -35,4 +35,8 @@ * 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 -r 7ec8dab190a7 -r 78d7cc9c9b18 src/mod_db.sml --- a/src/mod_db.sml Wed May 02 08:34:50 2012 -0400 +++ b/src/mod_db.sml Wed May 02 08:56:19 2012 -0400 @@ -141,4 +141,10 @@ NONE) | _ => NONE +val byNameBackup = ref (!byName) +val byIdBackup = ref (!byId) + +fun snapshot () = (byNameBackup := !byName; byIdBackup := !byId) +fun revert () = (byName := !byNameBackup; byId := !byIdBackup) + end diff -r 7ec8dab190a7 -r 78d7cc9c9b18 tests/baddep.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/baddep.urp Wed May 02 08:56:19 2012 -0400 @@ -0,0 +1,2 @@ +baddep1 +baddep2 diff -r 7ec8dab190a7 -r 78d7cc9c9b18 tests/baddep1.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/baddep1.ur Wed May 02 08:56:19 2012 -0400 @@ -0,0 +1,1 @@ +val x : int = "hi" diff -r 7ec8dab190a7 -r 78d7cc9c9b18 tests/baddep2.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/baddep2.ur Wed May 02 08:56:19 2012 -0400 @@ -0,0 +1,1 @@ +fun main () : transaction page = return