Skip to content

Commit

Permalink
Disallow cardinal diretion values without compass
Browse files Browse the repository at this point in the history
  • Loading branch information
xsebek committed Jun 10, 2022
1 parent 7cee36f commit 8911b10
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8911b10

Please sign in to comment.