disco 0.1.3.0 → 0.1.3.1
raw patch · 5 files changed
+23/−15 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Disco.Error: [UnboundPanic] :: Name core -> EvalError
- Disco.Effects.Counter: next :: forall r_ajvL. Member Counter r_ajvL => Sem r_ajvL Integer
+ Disco.Effects.Counter: next :: forall r_ajvR. Member Counter r_ajvR => Sem r_ajvR Integer
- Disco.Effects.Fresh: fresh :: forall r_a1KNp x_X1KMC. Member Fresh r_a1KNp => Name x_X1KMC -> Sem r_a1KNp (Name x_X1KMC)
+ Disco.Effects.Fresh: fresh :: forall r_a1KNv x_X1KMI. Member Fresh r_a1KNv => Name x_X1KMI -> Sem r_a1KNv (Name x_X1KMI)
- Disco.Effects.LFresh: avoid :: forall r_alvA a_alqY. Member LFresh r_alvA => [AnyName] -> Sem r_alvA a_alqY -> Sem r_alvA a_alqY
+ Disco.Effects.LFresh: avoid :: forall r_alvG a_alr4. Member LFresh r_alvG => [AnyName] -> Sem r_alvG a_alr4 -> Sem r_alvG a_alr4
- Disco.Effects.LFresh: getAvoids :: forall r_alvD. Member LFresh r_alvD => Sem r_alvD (Set AnyName)
+ Disco.Effects.LFresh: getAvoids :: forall r_alvJ. Member LFresh r_alvJ => Sem r_alvJ (Set AnyName)
- Disco.Effects.LFresh: lfresh :: forall r_alvy a_XlqW. (Member LFresh r_alvy, Typeable a_XlqW) => Name a_XlqW -> Sem r_alvy (Name a_XlqW)
+ Disco.Effects.LFresh: lfresh :: forall r_alvE a_Xlr2. (Member LFresh r_alvE, Typeable a_Xlr2) => Name a_Xlr2 -> Sem r_alvE (Name a_Xlr2)
- Disco.Effects.Store: assocsStore :: forall v_aomR r_aotg. Member (Store v_aomR) r_aotg => Sem r_aotg [(Int, v_aomR)]
+ Disco.Effects.Store: assocsStore :: forall v_aomX r_aotm. Member (Store v_aomX) r_aotm => Sem r_aotm [(Int, v_aomX)]
- Disco.Effects.Store: clearStore :: forall v_aomH r_aot6. Member (Store v_aomH) r_aot6 => Sem r_aot6 ()
+ Disco.Effects.Store: clearStore :: forall v_aomN r_aotc. Member (Store v_aomN) r_aotc => Sem r_aotc ()
- Disco.Effects.Store: insertStore :: forall v_aomN r_aotb. Member (Store v_aomN) r_aotb => Int -> v_aomN -> Sem r_aotb ()
+ Disco.Effects.Store: insertStore :: forall v_aomT r_aoth. Member (Store v_aomT) r_aoth => Int -> v_aomT -> Sem r_aoth ()
- Disco.Effects.Store: keepKeys :: forall v_aomT r_aoth. Member (Store v_aomT) r_aoth => IntSet -> Sem r_aoth ()
+ Disco.Effects.Store: keepKeys :: forall v_aomZ r_aotn. Member (Store v_aomZ) r_aotn => IntSet -> Sem r_aotn ()
- Disco.Effects.Store: lookupStore :: forall v_aomL r_aot9. Member (Store v_aomL) r_aot9 => Int -> Sem r_aot9 (Maybe v_aomL)
+ Disco.Effects.Store: lookupStore :: forall v_aomR r_aotf. Member (Store v_aomR) r_aotf => Int -> Sem r_aotf (Maybe v_aomR)
- Disco.Effects.Store: mapStore :: forall v_aomP r_aote. Member (Store v_aomP) r_aote => (v_aomP -> v_aomP) -> Sem r_aote ()
+ Disco.Effects.Store: mapStore :: forall v_aomV r_aotk. Member (Store v_aomV) r_aotk => (v_aomV -> v_aomV) -> Sem r_aotk ()
- Disco.Effects.Store: new :: forall v_aomJ r_aot7. Member (Store v_aomJ) r_aot7 => v_aomJ -> Sem r_aot7 Int
+ Disco.Effects.Store: new :: forall v_aomP r_aotd. Member (Store v_aomP) r_aotd => v_aomP -> Sem r_aotd Int
- Disco.Error: [UnboundError] :: Name core -> EvalError
+ Disco.Error: [UnboundError] :: QName core -> EvalError
Files
- CHANGELOG.md +6/−0
- disco.cabal +3/−3
- src/Disco/Error.hs +10/−4
- src/Disco/Interpret/CESK.hs +3/−7
- src/Disco/Value.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,9 @@+* 0.1.3.1 (5 March 2022)++ - Fix [#340](https://github.com/disco-lang/disco/issues/340): disco+ no longer crashes when encountering an undefined name at runtime,+ but prints a nice error message instead.+ * 0.1.3.0 (3 March 2022) - New features or syntax
disco.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: disco-version: 0.1.3.0+version: 0.1.3.1 synopsis: Functional programming language for teaching discrete math. description: Disco is a simple functional programming language for use in teaching discrete math. Its syntax is designed to be close@@ -466,7 +466,7 @@ QuickCheck >= 2.9 && < 2.15, splitmix >= 0.1 && < 0.2, fgl >= 5.5 && < 5.8,- optparse-applicative >= 0.12 && < 0.17,+ optparse-applicative >= 0.12 && < 0.18, oeis >= 0.3.10, algebraic-graphs >= 0.5, pretty-show >= 1.10@@ -489,7 +489,7 @@ containers >= 0.5 && < 0.7, unbound-generics >= 0.3 && < 0.5, lens >= 4.14 && < 5.2,- optparse-applicative >= 0.12 && < 0.17,+ optparse-applicative >= 0.12 && < 0.18, oeis >= 0.3.10 default-language: Haskell2010
src/Disco/Error.hs view
@@ -29,7 +29,7 @@ import Polysemy.Reader import Disco.Messages-import Disco.Names (ModuleName)+import Disco.Names (ModuleName, QName) import Disco.Parser (DiscoParseError) import Disco.Pretty import Disco.Typecheck.Solve@@ -65,9 +65,13 @@ -- | Errors that can be generated at runtime. data EvalError where - -- | An unbound name. This shouldn't happen.- UnboundError :: Name core -> EvalError+ -- | An unbound name was encountered.+ UnboundError :: QName core -> EvalError + -- | An unbound name that really shouldn't happen, coming from some+ -- kind of internal name generation scheme.+ UnboundPanic :: Name core -> EvalError+ -- | Division by zero. DivByZero :: EvalError @@ -128,10 +132,11 @@ prettyEvalError :: Members '[Reader PA, LFresh] r => EvalError -> Sem r Doc prettyEvalError = \case- UnboundError x ->+ UnboundPanic x -> ("Bug! No variable found named" <+> pretty' x <> ".") $+$ "Please report this as a bug at https://github.com/disco-lang/disco/issues/ ."+ UnboundError x -> "Error: encountered undefined name" <+> pretty' x <> ". Maybe you haven't defined it yet?" DivByZero -> "Error: division by zero." Overflow -> "Error: that number would not even fit in the universe!" NonExhaustive -> "Error: value did not match any of the branches in a case expression."@@ -147,6 +152,7 @@ prettyTCError = \case -- XXX include some potential misspellings along with Unbound+ -- see https://github.com/disco-lang/disco/issues/180 Unbound x -> vcat [ "Error: there is nothing named" <+> pretty' x <> "." , rtd "unbound"
src/Disco/Interpret/CESK.hs view
@@ -153,16 +153,12 @@ Just res -> return res Nothing -> step cesk >>= runCESK -(!!!) :: (Show a, Show b) => Ctx a b -> QName a -> b-ctx !!! x = case Ctx.lookup' x ctx of- Nothing -> error $ "variable " ++ show x ++ " not found in environment\n"- ++ ppShow (Ctx.keysSet ctx)- Just v -> v- -- | Advance the CESK machine by one step. step :: Members '[Fresh, Random, State Mem] r => CESK -> Sem r CESK step cesk = case cesk of- (In (CVar x) e k) -> return $ Out (e !!! x) k+ (In (CVar x) e k) -> case Ctx.lookup' x e of+ Nothing -> return $ Up (UnboundError x) k+ Just v -> return $ Out v k (In (CNum d r) _ k) -> return $ Out (VNum d r) k (In (CConst OMatchErr) _ k) -> return $ Up NonExhaustive k (In (CConst OEmptyGraph) _ k) -> return $ Out (VGraph empty) k
src/Disco/Value.hs view
@@ -303,7 +303,7 @@ let value = Ctx.lookup' (localName name) e case value of Just v -> return (s, ty, v)- Nothing -> Left (UnboundError name)+ Nothing -> Left (UnboundPanic name) -- | The possible outcomes of a property test, parametrized over -- the type of values. A @TestReason@ explains why a proposition