show error on duplicated level number

pull/116/head
Jon 3 years ago
parent c50517b5e6
commit 6e046d72b6

@ -382,6 +382,11 @@ def modifyCurWorld (fn : World → m World) [MonadError m] : m Unit := do
return {game with worlds := {game.worlds with nodes := game.worlds.nodes.insert world.name (← fn world) }} return {game with worlds := {game.worlds with nodes := game.worlds.nodes.insert world.name (← fn world) }}
def addLevel (level : GameLevel) [MonadError m] : m Unit := do def addLevel (level : GameLevel) [MonadError m] : m Unit := do
let worldId ← getCurWorldId
match ← getLevel? ⟨← getCurGameId, worldId, level.index⟩ with
| some _existingLevel =>
throwError m!"Level {level.index} already exists for world {worldId}!"
| none =>
modifyCurWorld fun world => do modifyCurWorld fun world => do
return {world with levels := world.levels.insert level.index level} return {world with levels := world.levels.insert level.index level}

@ -13,8 +13,11 @@ Level 1
Statement foo.bar : 5 ≤ 7 := by Statement foo.bar : 5 ≤ 7 := by
simp simp
-- Shows warning on `foo.bar₂`: Game "Test"
World "TestW"
Level 2 -- should warn if set to `1`
-- Shows warning on `foo.bar₂`:
Statement foo.bar2 : 3 ≤ 7 := by Statement foo.bar2 : 3 ≤ 7 := by
simp simp

Loading…
Cancel
Save