Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit c527f5e

Browse files
authored
Fixed LHS auto typing conversion for Expr arithmetic (#146)
Now Expr arithmetic doesn't require LHS to be Expr but can be ToExpr as well. Thanks to Sandro for pointing out this error.
1 parent 8e0b667 commit c527f5e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chiquito"
3-
version = "0.1.2023092400"
3+
version = "0.1.2023101100"
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
authors = ["Leo Lara <[email protected]>"]

src/frontend/python/chiquito/expr.py

+3
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,23 @@ def __add__(self: Expr, rhs: ToExpr) -> Sum:
2626
return Sum([self, rhs])
2727

2828
def __radd__(self: Expr, lhs: ToExpr) -> Sum:
29+
lhs = to_expr(lhs)
2930
return Expr.__add__(lhs, self)
3031

3132
def __sub__(self: Expr, rhs: ToExpr) -> Sum:
3233
rhs = to_expr(rhs)
3334
return Sum([self, Neg(rhs)])
3435

3536
def __rsub__(self: Expr, lhs: ToExpr) -> Sum:
37+
lhs = to_expr(lhs)
3638
return Expr.__sub__(lhs, self)
3739

3840
def __mul__(self: Expr, rhs: ToExpr) -> Mul:
3941
rhs = to_expr(rhs)
4042
return Mul([self, rhs])
4143

4244
def __rmul__(self: Expr, lhs: ToExpr) -> Mul:
45+
lhs = to_expr(lhs)
4346
return Expr.__mul__(lhs, self)
4447

4548
def __pow__(self: Expr, rhs: int) -> Pow:

0 commit comments

Comments
 (0)