@@ -9,6 +9,7 @@ import scala.collection.immutable._
9
9
import scala .annotation ._
10
10
import shorthands ._
11
11
import scala .collection .mutable .ListBuffer
12
+ import scala .util .boundary , boundary .break
12
13
13
14
enum Stuck :
14
15
case StuckExpr (expr : Expr , msg : Str )
@@ -102,12 +103,13 @@ class Interpreter(verbose: Bool):
102
103
case Value .Class (cls2, xs) => L (StuckExpr (expr, s " unexpected class $cls2" ))
103
104
case x => L (StuckExpr (expr, s " unexpected value $x" ))
104
105
}
105
- case BasicOp (name, args) =>
106
+ case BasicOp (name, args) => boundary :
106
107
evalArgs(args).flatMap(
107
108
xs =>
108
109
name match
109
110
case " +" | " -" | " *" | " /" | " ==" | " !=" | " <=" | " >=" | " <" | " >" =>
110
- if xs.length < 2 then return L (StuckExpr (expr, s " not enough arguments for basic operation $name" ))
111
+ if xs.length < 2 then break :
112
+ L (StuckExpr (expr, s " not enough arguments for basic operation $name" ))
111
113
else eval(name, xs.head, xs.tail.head).toRight(StuckExpr (expr, s " unable to evaluate basic operation " ))
112
114
case _ => L (StuckExpr (expr, s " unexpected basic operation $name" )))
113
115
case AssignField (assignee, cls, field, value) =>
0 commit comments