diff --git a/src/Swarm/Game/Step.hs b/src/Swarm/Game/Step.hs index b338ca16c3..6be81b25c3 100644 --- a/src/Swarm/Game/Step.hs +++ b/src/Swarm/Game/Step.hs @@ -374,10 +374,20 @@ stepCESK cesk = case cesk of -- Now some straightforward cases. These all immediately turn -- into values. In TUnit _ s k -> return $ Out VUnit s k - In (TDir d) _ s k -> return $ Out (VDir d) s k In (TInt n) _ s k -> return $ Out (VInt n) s k In (TString str) _ s k -> return $ Out (VString str) s k In (TBool b) _ s k -> return $ Out (VBool b) s k + + -- Direction is simple too unless it is absolute (e.g. north) + -- and needs orient capability (provided by a compass). + -- This may be redundant just because of base escaping + -- capability checking (see #231). + In (TDir d) _ s k -> do + orient <- hasCapability COrient + if isCardinal d && not orient + then return $ Up (Incapable (S.singleton COrient) (TDir d)) s [] + else return $ Out (VDir d) s k + -- There should not be any antiquoted variables left at this point. In (TAntiString v) _ s k -> return $ Up (Fatal (T.append "Antiquoted variable found at runtime: $str:" v)) s k