Skip to content

Improve complex binop and add .real, .imag attributes #232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 76 additions & 4 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,13 +1014,42 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
al, right->base.loc, right, ASR::cast_kindType::RealToReal,
left_type, nullptr));
}
} else if (ASRUtils::is_complex(*left_type) && ASRUtils::is_complex(*right_type)) {
bool is_l64 = ASR::down_cast<ASR::Complex_t>(left_type)->m_kind == 8;
bool is_r64 = ASR::down_cast<ASR::Complex_t>(right_type)->m_kind == 8;
if (is_assign) {
if (is_l64 != is_r64) {
// here we need to cast to left type strictly
return ASR::down_cast<ASR::expr_t>(ASR::make_ImplicitCast_t(
al, right->base.loc, right, ASR::cast_kindType::ComplexToComplex,
left_type, nullptr));
}
} else if (is_l64 && !is_r64) {
return ASR::down_cast<ASR::expr_t>(ASR::make_ImplicitCast_t(
al, right->base.loc, right, ASR::cast_kindType::ComplexToComplex,
left_type, nullptr));
}
} else if (!is_assign && ASRUtils::is_real(*left_type) && ASRUtils::is_integer(*right_type)) {
return ASR::down_cast<ASR::expr_t>(ASR::make_ImplicitCast_t(
al, right->base.loc, right, ASR::cast_kindType::IntegerToReal,
left_type, nullptr));
} else if (is_assign && ASRUtils::is_real(*left_type) && ASRUtils::is_integer(*right_type)) {
throw SemanticError("Assigning integer to float is not supported",
right->base.loc);
} else if (ASRUtils::is_complex(*left_type) && !ASRUtils::is_complex(*right_type)) {
if (ASRUtils::is_real(*right_type)) {
return ASR::down_cast<ASR::expr_t>(ASR::make_ImplicitCast_t(
Comment on lines +1039 to +1041
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change this to

Suggested change
} else if (ASRUtils::is_complex(*left_type) && !ASRUtils::is_complex(*right_type)) {
if (ASRUtils::is_real(*right_type)) {
return ASR::down_cast<ASR::expr_t>(ASR::make_ImplicitCast_t(
} else if (!is_assign && ASRUtils::is_complex(*left_type) && !ASRUtils::is_complex(*right_type)) {
if (ASRUtils::is_real(*right_type)) {
return ASR::down_cast<ASR::expr_t>(ASR::make_ImplicitCast_t(

al, right->base.loc, right, ASR::cast_kindType::RealToComplex,
left_type, nullptr));
} else if (ASRUtils::is_integer(*right_type)) {
return ASR::down_cast<ASR::expr_t>(ASR::make_ImplicitCast_t(
al, right->base.loc, right, ASR::cast_kindType::IntegerToComplex,
left_type, nullptr));
} else {
std::string rtype = ASRUtils::type_to_str(right_type);
throw SemanticError("Casting " + rtype + " to complex is not Implemented",
right->base.loc);
}
}
return right;
}
Expand Down Expand Up @@ -1065,6 +1094,49 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
}
}

void visit_Attribute(const AST::Attribute_t &x) {
if (AST::is_a<AST::Name_t>(*x.m_value)) {
std::string value = AST::down_cast<AST::Name_t>(x.m_value)->m_id;
ASR::symbol_t *t = current_scope->scope[value];
if (!t) {
throw SemanticError("'" + value + "' is not defined in the scope",
x.base.base.loc);
}
if (ASR::is_a<ASR::Variable_t>(*t)) {
ASR::Variable_t *var = ASR::down_cast<ASR::Variable_t>(t);
LFORTRAN_ASSERT(var->m_value);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presently this fails on the following check:

def test():
    x: c64
    x = 2 + 3j
    a: f64
    a = x.imag

ASR:

AssertFailed: var->m_value

This might be because we are keeping value as nullptr while creating a variable which I expect to be changed after the assignment. @certik What are your views/suggestions on this?

if (ASR::is_a<ASR::ConstantComplex_t>(*var->m_value)) {
std::string attr = x.m_attr;
if (attr == "imag") {
double val = ASR::down_cast<ASR::ConstantComplex_t>(var->m_value)->m_im;
ASR::ttype_t *type = ASRUtils::TYPE(ASR::make_Real_t(al, x.base.base.loc,
8, nullptr, 0));
tmp = ASR::make_ConstantReal_t(al, x.base.base.loc, val, type);
} else if (attr == "real") {
double val = ASR::down_cast<ASR::ConstantComplex_t>(var->m_value)->m_im;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix this:

Suggested change
double val = ASR::down_cast<ASR::ConstantComplex_t>(var->m_value)->m_im;
double val = ASR::down_cast<ASR::ConstantComplex_t>(var->m_value)->m_re;

ASR::ttype_t *type = ASRUtils::TYPE(ASR::make_Real_t(al, x.base.base.loc,
8, nullptr, 0));
tmp = ASR::make_ConstantReal_t(al, x.base.base.loc, val, type);
} else {
throw SemanticError("'" + attr + "' is not implemented for Complex type",
x.base.base.loc);
}

} else {
throw SemanticError("Only Complex type supported for now in Attribute",
x.base.base.loc);
}
} else {
throw SemanticError("Only Variable type is supported for now in Attribute",
x.base.base.loc);
}

} else {
throw SemanticError("Only Name is supported for now in Attribute",
x.base.base.loc);
}
}

void visit_Assert(const AST::Assert_t &x) {
this->visit_expr(*x.m_test);
ASR::expr_t *test = ASRUtils::EXPR(tmp);
Expand Down Expand Up @@ -1392,8 +1464,10 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
value));
}
}
} else if((ASRUtils::is_integer(*left_type) || ASRUtils::is_real(*left_type)) &&
(ASRUtils::is_integer(*right_type) || ASRUtils::is_real(*right_type)) ){
} else if((ASRUtils::is_integer(*left_type) || ASRUtils::is_real(*left_type) ||
ASRUtils::is_complex(*left_type)) &&
(ASRUtils::is_integer(*right_type) || ASRUtils::is_real(*right_type) ||
ASRUtils::is_complex(*right_type))) {
left = implicitcast_helper(ASRUtils::expr_type(right), left);
right = implicitcast_helper(ASRUtils::expr_type(left), right);
dest_type = ASRUtils::expr_type(left);
Expand Down Expand Up @@ -1467,8 +1541,6 @@ class BodyVisitor : public CommonVisitor<BodyVisitor> {
value);
return;

} else if (ASRUtils::is_complex(*left_type) && ASRUtils::is_complex(*right_type)) {
dest_type = left_type;
} else if (ASRUtils::is_logical(*left_type) && ASRUtils::is_logical(*right_type)) {
dest_type = left_type;
} else {
Expand Down
11 changes: 11 additions & 0 deletions tests/complex1.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ def test_complex():
c = complex(1, 2) ** complex(3.34534, 4.8678678)
c = complex(1, 2) * complex(3, 4)
c = complex(4, 5) - complex(3, 4)


def test():
x: c64
y: c64
z: c64
x = 2 + 3j
y = 5 + 5j
z = x + y
z = x - y
z = 2 * x
4 changes: 2 additions & 2 deletions tests/reference/asr-complex1-f26c460.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"basename": "asr-complex1-f26c460",
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
"infile": "tests/complex1.py",
"infile_hash": "e5e897465f4a0e1e59bcde88e49ce7adb1ddb84283450b631d5479f7",
"infile_hash": "651cffa820748667c774f75291eed77bb0706236de41d6f25a779106",
"outfile": null,
"outfile_hash": null,
"stdout": "asr-complex1-f26c460.stdout",
"stdout_hash": "3d30525175033241e93db499e684dd2744b4272da6e49756d4a9aa46",
"stdout_hash": "bd2408b259465bb2d8afecec3dae041c24f3e1570dd6f32c082ea8e6",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-complex1-f26c460.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {main_program: (Program (SymbolTable 3 {}) main_program [] []), test_complex: (Subroutine (SymbolTable 2 {b: (Variable 2 b Local () () Default (Logical 1 []) Source Public Required .false.), c: (Variable 2 c Local () () Default (Complex 4 []) Source Public Required .false.), c1: (Variable 2 c1 Local () () Default (Complex 4 []) Source Public Required .false.), c2: (Variable 2 c2 Local () () Default (Complex 4 []) Source Public Required .false.), c3: (Variable 2 c3 Local () () Default (Complex 8 []) Source Public Required .false.)}) test_complex [] [(= (Var 2 c) (ConstantComplex 0.000000 0.000000 (Complex 8 [])) ()) (= (Var 2 c) (ConstantComplex 3.400000 0.000000 (Complex 8 [])) ()) (= (Var 2 c) (ConstantComplex 5.000000 4.300000 (Complex 8 [])) ()) (= (Var 2 c) (ConstantComplex 1.000000 0.000000 (Complex 8 [])) ()) (= (Var 2 c1) (ConstantComplex 3.000000 4.000000 (Complex 8 [])) ()) (= (Var 2 c2) (ConstantComplex 2.000000 4.500000 (Complex 8 [])) ()) (= (Var 2 c3) (ConstantComplex 3.000000 4.000000 (Complex 8 [])) ()) (= (Var 2 b) (Compare (Var 2 c1) NotEq (Var 2 c2) (Logical 4 []) () ()) ()) (= (Var 2 b) (Compare (Var 2 c1) Eq (Var 2 c3) (Logical 4 []) () ()) ()) (= (Var 2 c) (BinOp (Var 2 c1) Add (Var 2 c2) (Complex 4 []) () ()) ()) (= (Var 2 c) (BinOp (Var 2 c2) Sub (Var 2 c1) (Complex 4 []) () ()) ()) (= (Var 2 c) (BinOp (Var 2 c1) Mul (Var 2 c2) (Complex 4 []) () ()) ()) (= (Var 2 c) (BinOp (ConstantComplex 1.000000 2.000000 (Complex 8 [])) Pow (ConstantComplex 3.345340 4.867868 (Complex 8 [])) (Complex 8 []) (ConstantComplex 0.015553 0.065561 (Complex 8 [])) ()) ()) (= (Var 2 c) (BinOp (ConstantComplex 1.000000 2.000000 (Complex 8 [])) Mul (ConstantComplex 3.000000 4.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex -5.000000 10.000000 (Complex 8 [])) ()) ()) (= (Var 2 c) (BinOp (ConstantComplex 4.000000 5.000000 (Complex 8 [])) Sub (ConstantComplex 3.000000 4.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex 1.000000 1.000000 (Complex 8 [])) ()) ())] Source Public Implementation () .false. .false.)}) [])
(TranslationUnit (SymbolTable 1 {main_program: (Program (SymbolTable 4 {}) main_program [] []), test: (Subroutine (SymbolTable 3 {x: (Variable 3 x Local () () Default (Complex 8 []) Source Public Required .false.), y: (Variable 3 y Local () () Default (Complex 8 []) Source Public Required .false.), z: (Variable 3 z Local () () Default (Complex 8 []) Source Public Required .false.)}) test [] [(= (Var 3 x) (BinOp (ImplicitCast (ConstantInteger 2 (Integer 4 [])) IntegerToComplex (Complex 8 []) ()) Add (ConstantComplex 0.000000 3.000000 (Complex 8 [])) (Complex 8 []) () ()) ()) (= (Var 3 y) (BinOp (ImplicitCast (ConstantInteger 5 (Integer 4 [])) IntegerToComplex (Complex 8 []) ()) Add (ConstantComplex 0.000000 5.000000 (Complex 8 [])) (Complex 8 []) () ()) ()) (= (Var 3 z) (BinOp (Var 3 x) Add (Var 3 y) (Complex 8 []) () ()) ()) (= (Var 3 z) (BinOp (Var 3 x) Sub (Var 3 y) (Complex 8 []) () ()) ()) (= (Var 3 z) (BinOp (ImplicitCast (ConstantInteger 2 (Integer 4 [])) IntegerToComplex (Complex 8 []) ()) Mul (Var 3 x) (Complex 8 []) () ()) ())] Source Public Implementation () .false. .false.), test_complex: (Subroutine (SymbolTable 2 {b: (Variable 2 b Local () () Default (Logical 1 []) Source Public Required .false.), c: (Variable 2 c Local () () Default (Complex 4 []) Source Public Required .false.), c1: (Variable 2 c1 Local () () Default (Complex 4 []) Source Public Required .false.), c2: (Variable 2 c2 Local () () Default (Complex 4 []) Source Public Required .false.), c3: (Variable 2 c3 Local () () Default (Complex 8 []) Source Public Required .false.)}) test_complex [] [(= (Var 2 c) (ImplicitCast (ConstantComplex 0.000000 0.000000 (Complex 8 [])) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c) (ImplicitCast (ConstantComplex 3.400000 0.000000 (Complex 8 [])) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c) (ImplicitCast (ConstantComplex 5.000000 4.300000 (Complex 8 [])) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c) (ImplicitCast (ConstantComplex 1.000000 0.000000 (Complex 8 [])) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c1) (ImplicitCast (ConstantComplex 3.000000 4.000000 (Complex 8 [])) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c2) (ImplicitCast (ConstantComplex 2.000000 4.500000 (Complex 8 [])) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c3) (ConstantComplex 3.000000 4.000000 (Complex 8 [])) ()) (= (Var 2 b) (Compare (Var 2 c1) NotEq (Var 2 c2) (Logical 4 []) () ()) ()) (= (Var 2 b) (Compare (ImplicitCast (Var 2 c1) ComplexToComplex (Complex 8 []) ()) Eq (Var 2 c3) (Logical 4 []) () ()) ()) (= (Var 2 c) (BinOp (Var 2 c1) Add (Var 2 c2) (Complex 4 []) () ()) ()) (= (Var 2 c) (BinOp (Var 2 c2) Sub (Var 2 c1) (Complex 4 []) () ()) ()) (= (Var 2 c) (BinOp (Var 2 c1) Mul (Var 2 c2) (Complex 4 []) () ()) ()) (= (Var 2 c) (ImplicitCast (BinOp (ConstantComplex 1.000000 2.000000 (Complex 8 [])) Pow (ConstantComplex 3.345340 4.867868 (Complex 8 [])) (Complex 8 []) (ConstantComplex 0.015553 0.065561 (Complex 8 [])) ()) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c) (ImplicitCast (BinOp (ConstantComplex 1.000000 2.000000 (Complex 8 [])) Mul (ConstantComplex 3.000000 4.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex -5.000000 10.000000 (Complex 8 [])) ()) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c) (ImplicitCast (BinOp (ConstantComplex 4.000000 5.000000 (Complex 8 [])) Sub (ConstantComplex 3.000000 4.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex 1.000000 1.000000 (Complex 8 [])) ()) ComplexToComplex (Complex 4 []) ()) ())] Source Public Implementation () .false. .false.)}) [])
2 changes: 1 addition & 1 deletion tests/reference/asr-expr10-efcbb1b.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr10-efcbb1b.stdout",
"stdout_hash": "35d921142ec8c2aa5bd5c9a9c43b4c172a0d9907a8b6e457849e3782",
"stdout_hash": "e763d27dad09a6d48e2bd1dce6a41eb9418c17b98e3d6f883d1fea54",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr10-efcbb1b.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {main_program: (Program (SymbolTable 3 {}) main_program [] []), test_UnaryOp: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Logical 1 []) Source Public Required .false.), b1: (Variable 2 b1 Local () () Default (Logical 1 []) Source Public Required .false.), b2: (Variable 2 b2 Local () () Default (Logical 1 []) Source Public Required .false.), b3: (Variable 2 b3 Local () () Default (Logical 1 []) Source Public Required .false.), c: (Variable 2 c Local () () Default (Complex 4 []) Source Public Required .false.), f: (Variable 2 f Local () () Default (Real 4 []) Source Public Required .false.)}) test_UnaryOp [] [(= (Var 2 a) (UnaryOp UAdd (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger 4 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp USub (ConstantInteger 500 (Integer 4 [])) (Integer 4 []) (ConstantInteger -500 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp Invert (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -6 (Integer 4 []))) ()) (= (Var 2 b) (UnaryOp Not (ConstantInteger 5 (Integer 4 [])) (Logical 4 []) (ConstantLogical .false. (Logical 4 []))) ()) (= (Var 2 b) (UnaryOp Not (UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 []))) (Logical 4 []) (ConstantLogical .false. (Logical 4 []))) ()) (= (Var 2 b) (UnaryOp Not (ConstantInteger 0 (Integer 4 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 []))) ()) (= (Var 2 f) (ImplicitCast (UnaryOp UAdd (ConstantReal 1.000000 (Real 8 [])) (Real 8 []) (ConstantReal 1.000000 (Real 8 []))) RealToReal (Real 4 []) ()) ()) (= (Var 2 f) (ImplicitCast (UnaryOp USub (ConstantReal 183745.534000 (Real 8 [])) (Real 8 []) (ConstantReal -183745.534000 (Real 8 []))) RealToReal (Real 4 []) ()) ()) (= (Var 2 b1) (ConstantLogical .true. (Logical 1 [])) ()) (= (Var 2 b2) (UnaryOp Not (ConstantLogical .false. (Logical 1 [])) (Logical 1 []) (ConstantLogical .true. (Logical 4 []))) ()) (= (Var 2 b3) (UnaryOp Not (Var 2 b2) (Logical 1 []) ()) ()) (= (Var 2 a) (UnaryOp UAdd (ConstantLogical .true. (Logical 1 [])) (Integer 4 []) (ConstantInteger 1 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp USub (ConstantLogical .false. (Logical 1 [])) (Integer 4 []) (ConstantInteger 0 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp Invert (ConstantLogical .true. (Logical 1 [])) (Integer 4 []) (ConstantInteger -2 (Integer 4 []))) ()) (= (Var 2 c) (UnaryOp UAdd (ConstantComplex 1.000000 2.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex 1.000000 2.000000 (Complex 8 []))) ()) (= (Var 2 c) (UnaryOp USub (ConstantComplex 3.000000 65.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex -3.000000 -65.000000 (Complex 8 []))) ()) (= (Var 2 b1) (UnaryOp Not (ConstantComplex 3.000000 4.000000 (Complex 8 [])) (Logical 4 []) (ConstantLogical .false. (Logical 4 []))) ()) (= (Var 2 b2) (UnaryOp Not (ConstantComplex 0.000000 0.000000 (Complex 8 [])) (Logical 4 []) (ConstantLogical .true. (Logical 4 []))) ())] Source Public Implementation () .false. .false.)}) [])
(TranslationUnit (SymbolTable 1 {main_program: (Program (SymbolTable 3 {}) main_program [] []), test_UnaryOp: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Logical 1 []) Source Public Required .false.), b1: (Variable 2 b1 Local () () Default (Logical 1 []) Source Public Required .false.), b2: (Variable 2 b2 Local () () Default (Logical 1 []) Source Public Required .false.), b3: (Variable 2 b3 Local () () Default (Logical 1 []) Source Public Required .false.), c: (Variable 2 c Local () () Default (Complex 4 []) Source Public Required .false.), f: (Variable 2 f Local () () Default (Real 4 []) Source Public Required .false.)}) test_UnaryOp [] [(= (Var 2 a) (UnaryOp UAdd (ConstantInteger 4 (Integer 4 [])) (Integer 4 []) (ConstantInteger 4 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp USub (ConstantInteger 500 (Integer 4 [])) (Integer 4 []) (ConstantInteger -500 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp Invert (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantInteger -6 (Integer 4 []))) ()) (= (Var 2 b) (UnaryOp Not (ConstantInteger 5 (Integer 4 [])) (Integer 4 []) (ConstantLogical .false. (Logical 4 []))) ()) (= (Var 2 b) (UnaryOp Not (UnaryOp USub (ConstantInteger 1 (Integer 4 [])) (Integer 4 []) (ConstantInteger -1 (Integer 4 []))) (Integer 4 []) (ConstantLogical .false. (Logical 4 []))) ()) (= (Var 2 b) (UnaryOp Not (ConstantInteger 0 (Integer 4 [])) (Integer 4 []) (ConstantLogical .true. (Logical 4 []))) ()) (= (Var 2 f) (ImplicitCast (UnaryOp UAdd (ConstantReal 1.000000 (Real 8 [])) (Real 8 []) (ConstantReal 1.000000 (Real 8 []))) RealToReal (Real 4 []) ()) ()) (= (Var 2 f) (ImplicitCast (UnaryOp USub (ConstantReal 183745.534000 (Real 8 [])) (Real 8 []) (ConstantReal -183745.534000 (Real 8 []))) RealToReal (Real 4 []) ()) ()) (= (Var 2 b1) (ConstantLogical .true. (Logical 1 [])) ()) (= (Var 2 b2) (UnaryOp Not (ConstantLogical .false. (Logical 1 [])) (Logical 1 []) (ConstantLogical .true. (Logical 4 []))) ()) (= (Var 2 b3) (UnaryOp Not (Var 2 b2) (Logical 1 []) ()) ()) (= (Var 2 a) (UnaryOp UAdd (ConstantLogical .true. (Logical 1 [])) (Logical 1 []) (ConstantInteger 1 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp USub (ConstantLogical .false. (Logical 1 [])) (Logical 1 []) (ConstantInteger 0 (Integer 4 []))) ()) (= (Var 2 a) (UnaryOp Invert (ConstantLogical .true. (Logical 1 [])) (Logical 1 []) (ConstantInteger -2 (Integer 4 []))) ()) (= (Var 2 c) (ImplicitCast (UnaryOp UAdd (ConstantComplex 1.000000 2.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex 1.000000 2.000000 (Complex 8 []))) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 c) (ImplicitCast (UnaryOp USub (ConstantComplex 3.000000 65.000000 (Complex 8 [])) (Complex 8 []) (ConstantComplex -3.000000 -65.000000 (Complex 8 []))) ComplexToComplex (Complex 4 []) ()) ()) (= (Var 2 b1) (UnaryOp Not (ConstantComplex 3.000000 4.000000 (Complex 8 [])) (Complex 8 []) (ConstantLogical .false. (Logical 4 []))) ()) (= (Var 2 b2) (UnaryOp Not (ConstantComplex 0.000000 0.000000 (Complex 8 [])) (Complex 8 []) (ConstantLogical .true. (Logical 4 []))) ())] Source Public Implementation () .false. .false.)}) [])
4 changes: 2 additions & 2 deletions tests/reference/ast-complex1-800b4bb.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"basename": "ast-complex1-800b4bb",
"cmd": "lpython --show-ast --no-color {infile} -o {outfile}",
"infile": "tests/complex1.py",
"infile_hash": "e5e897465f4a0e1e59bcde88e49ce7adb1ddb84283450b631d5479f7",
"infile_hash": "651cffa820748667c774f75291eed77bb0706236de41d6f25a779106",
"outfile": null,
"outfile_hash": null,
"stdout": "ast-complex1-800b4bb.stdout",
"stdout_hash": "90fc1deef6ad16c1f2bb64550c84699e09c23fc39b34b28f97c143f4",
"stdout_hash": "10c37f72814e9e59a3c31481c43dd8c5ee41f4b0ca4d5c1ebf43ff1c",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
Loading