@@ -51,7 +51,7 @@ pub enum UnaryOps {
51
51
}
52
52
53
53
impl UnaryOps {
54
- fn default_type ( & self ) -> Type {
54
+ fn default_args_type ( & self ) -> Type {
55
55
match self {
56
56
UnaryOps :: Neg => Type :: Float ,
57
57
_ => Type :: Bool ,
@@ -80,9 +80,18 @@ pub enum BinaryOps {
80
80
}
81
81
82
82
impl BinaryOps {
83
- fn default_type ( & self ) -> Type {
83
+ fn default_args_type ( & self ) -> Type {
84
84
match self {
85
- BinaryOps :: Add | BinaryOps :: Sub | BinaryOps :: Mul | BinaryOps :: Div => Type :: Float ,
85
+ BinaryOps :: Add
86
+ | BinaryOps :: Sub
87
+ | BinaryOps :: Mul
88
+ | BinaryOps :: Div
89
+ | BinaryOps :: Lt
90
+ | BinaryOps :: Le
91
+ | BinaryOps :: Gt
92
+ | BinaryOps :: Ge
93
+ | BinaryOps :: Eq
94
+ | BinaryOps :: Neq => Type :: Float ,
86
95
_ => Type :: Bool ,
87
96
}
88
97
}
@@ -124,12 +133,12 @@ impl<'src> Expr<'src> {
124
133
op,
125
134
interval : _,
126
135
arg : _,
127
- } => op. default_type ( ) ,
136
+ } => op. default_args_type ( ) ,
128
137
Expr :: Binary {
129
138
op,
130
139
interval : _,
131
140
args : _,
132
- } => op. default_type ( ) ,
141
+ } => op. default_args_type ( ) ,
133
142
}
134
143
}
135
144
@@ -142,7 +151,7 @@ impl<'src> Expr<'src> {
142
151
}
143
152
144
153
fn unary_op ( op : UnaryOps , arg : Spanned < Self > , interval : Option < Spanned < Interval < ' src > > > ) -> Self {
145
- let arg = Box :: new ( ( arg. 0 . make_typed ( op. default_type ( ) ) , arg. 1 ) ) ;
154
+ let arg = Box :: new ( ( arg. 0 . make_typed ( op. default_args_type ( ) ) , arg. 1 ) ) ;
146
155
Self :: Unary { op, interval, arg }
147
156
}
148
157
@@ -156,7 +165,7 @@ impl<'src> Expr<'src> {
156
165
157
166
let common_type = lhs. get_type ( ) . get_common_cast ( rhs. get_type ( ) ) ;
158
167
let common_type = if Type :: Unknown == common_type {
159
- op. default_type ( )
168
+ op. default_args_type ( )
160
169
} else {
161
170
common_type
162
171
} ;
0 commit comments