mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:54:44 +01:00
Adds division to multiplicative expression. (#2091)
* Multiplication and division have the same priority. * A new builtin interface DivWith is added. * In some tests expecting a compilation error (syntax error), the error message now says it is expecting SLASH or binary *.
This commit is contained in:
@@ -192,6 +192,9 @@ auto Interpreter::EvalPrim(Operator op, Nonnull<const Value*> static_type,
|
||||
case Operator::Mul:
|
||||
return arena_->New<IntValue>(cast<IntValue>(*args[0]).value() *
|
||||
cast<IntValue>(*args[1]).value());
|
||||
case Operator::Div:
|
||||
return arena_->New<IntValue>(cast<IntValue>(*args[0]).value() /
|
||||
cast<IntValue>(*args[1]).value());
|
||||
case Operator::Mod:
|
||||
return arena_->New<IntValue>(cast<IntValue>(*args[0]).value() %
|
||||
cast<IntValue>(*args[1]).value());
|
||||
|
||||
Reference in New Issue
Block a user