Skip to content

Commit

Permalink
Bug fixes and reference test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
czgdp1807 committed Jul 19, 2022
1 parent 04af561 commit ca4a002
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ class CommonVisitor : public AST::BaseVisitor<Derived> {
comptime_val = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, value_int - 1, itype));
}
dim.m_start = zero;
dim.m_end = ASRUtils::compute_end_from_start_length(al, dim.m_start,
dim.m_length = ASRUtils::compute_length_from_start_end(al, dim.m_start,
ASRUtils::EXPR(ASR::make_IntegerBinOp_t(al, value->base.loc,
value, ASR::binopType::Sub, one, itype, comptime_val)));
dims.push_back(al, dim);
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_02_decl-e8f6874.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-array_02_decl-e8f6874.stdout",
"stdout_hash": "f45c320c9714cd62a564152d0cdafebfdab18ea352a46ccee7426d49",
"stdout_hash": "81929bfe053c351146c49f1eb90403240e0f2070392be8ee7f2ba867",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_02_decl-e8f6874.stdout
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Subroutine (SymbolTable 8 {}) _lpython_main_program [] [(SubroutineCall 1 declare_arrays () [] ())] Source Public Implementation () .false. .false.), accept_multidim_f32_array: (Function (SymbolTable 4 {_lpython_return_variable: (Variable 4 _lpython_return_variable ReturnVar () () Default (Real 4 []) Source Public Required .false.), xf32: (Variable 4 xf32 InOut () () Default (Real 4 [(() ())]) Source Public Required .false.)}) accept_multidim_f32_array [(Var 4 xf32)] [(= (Var 4 _lpython_return_variable) (ArrayItem (Var 4 xf32) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Real 4 []) ()) ()) (Return)] (Var 4 _lpython_return_variable) Source Public Implementation ()), accept_multidim_f64_array: (Function (SymbolTable 5 {_lpython_return_variable: (Variable 5 _lpython_return_variable ReturnVar () () Default (Real 8 []) Source Public Required .false.), xf64: (Variable 5 xf64 InOut () () Default (Real 8 [(() ()) (() ())]) Source Public Required .false.)}) accept_multidim_f64_array [(Var 5 xf64)] [(= (Var 5 _lpython_return_variable) (ArrayItem (Var 5 xf64) [(() (IntegerConstant 0 (Integer 4 [])) ()) (() (IntegerConstant 1 (Integer 4 [])) ())] (Real 8 []) ()) ()) (Return)] (Var 5 _lpython_return_variable) Source Public Implementation ()), accept_multidim_i32_array: (Function (SymbolTable 2 {_lpython_return_variable: (Variable 2 _lpython_return_variable ReturnVar () () Default (Integer 4 []) Source Public Required .false.), xi32: (Variable 2 xi32 InOut () () Default (Integer 4 [(() ()) (() ())]) Source Public Required .false.)}) accept_multidim_i32_array [(Var 2 xi32)] [(= (Var 2 _lpython_return_variable) (ArrayItem (Var 2 xi32) [(() (IntegerConstant 0 (Integer 4 [])) ()) (() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 4 []) ()) ()) (Return)] (Var 2 _lpython_return_variable) Source Public Implementation ()), accept_multidim_i64_array: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable ReturnVar () () Default (Integer 8 []) Source Public Required .false.), xi64: (Variable 3 xi64 InOut () () Default (Integer 8 [(() ()) (() ()) (() ())]) Source Public Required .false.)}) accept_multidim_i64_array [(Var 3 xi64)] [(= (Var 3 _lpython_return_variable) (ArrayItem (Var 3 xi64) [(() (IntegerConstant 9 (Integer 4 [])) ()) (() (IntegerConstant 9 (Integer 4 [])) ()) (() (IntegerConstant 9 (Integer 4 [])) ())] (Integer 8 []) ()) ()) (Return)] (Var 3 _lpython_return_variable) Source Public Implementation ()), declare_arrays: (Subroutine (SymbolTable 6 {ac32: (Variable 6 ac32 Local () () Default (Complex 4 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 5 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 4 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 99 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 98 (Integer 4 []))))]) Source Public Required .false.), ac64: (Variable 6 ac64 Local () () Default (Complex 8 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 13 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 12 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 11 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 10 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 16 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 15 (Integer 4 []))))]) Source Public Required .false.), af32: (Variable 6 af32 Local () () Default (Real 4 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 []))))]) Source Public Required .false.), af64: (Variable 6 af64 Local () () Default (Real 8 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 4 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 3 (Integer 4 []))))]) Source Public Required .false.), ai32: (Variable 6 ai32 Local () () Default (Integer 4 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 []))))]) Source Public Required .false.), ai64: (Variable 6 ai64 Local () () Default (Integer 8 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 []))))]) Source Public Required .false.)}) declare_arrays [] [(Print () [(FunctionCall 1 accept_multidim_i32_array () [((Var 6 ai32))] (Integer 4 []) () ())] () ()) (Print () [(FunctionCall 1 accept_multidim_i64_array () [((Var 6 ai64))] (Integer 8 []) () ())] () ()) (Print () [(FunctionCall 1 accept_multidim_f32_array () [((Var 6 af32))] (Real 4 []) () ())] () ()) (Print () [(FunctionCall 1 accept_multidim_f64_array () [((Var 6 af64))] (Real 8 []) () ())] () ())] Source Public Implementation () .false. .false.), main_program: (Program (SymbolTable 7 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) [])
(TranslationUnit (SymbolTable 1 {_lpython_main_program: (Subroutine (SymbolTable 8 {}) _lpython_main_program [] [(SubroutineCall 1 declare_arrays () [] ())] Source Public Implementation () .false. .false.), accept_multidim_f32_array: (Function (SymbolTable 4 {_lpython_return_variable: (Variable 4 _lpython_return_variable ReturnVar () () Default (Real 4 []) Source Public Required .false.), xf32: (Variable 4 xf32 InOut () () Default (Real 4 [(() ())]) Source Public Required .false.)}) accept_multidim_f32_array [(Var 4 xf32)] [(= (Var 4 _lpython_return_variable) (ArrayItem (Var 4 xf32) [(() (IntegerConstant 0 (Integer 4 [])) ())] (Real 4 []) ()) ()) (Return)] (Var 4 _lpython_return_variable) Source Public Implementation ()), accept_multidim_f64_array: (Function (SymbolTable 5 {_lpython_return_variable: (Variable 5 _lpython_return_variable ReturnVar () () Default (Real 8 []) Source Public Required .false.), xf64: (Variable 5 xf64 InOut () () Default (Real 8 [(() ()) (() ())]) Source Public Required .false.)}) accept_multidim_f64_array [(Var 5 xf64)] [(= (Var 5 _lpython_return_variable) (ArrayItem (Var 5 xf64) [(() (IntegerConstant 0 (Integer 4 [])) ()) (() (IntegerConstant 1 (Integer 4 [])) ())] (Real 8 []) ()) ()) (Return)] (Var 5 _lpython_return_variable) Source Public Implementation ()), accept_multidim_i32_array: (Function (SymbolTable 2 {_lpython_return_variable: (Variable 2 _lpython_return_variable ReturnVar () () Default (Integer 4 []) Source Public Required .false.), xi32: (Variable 2 xi32 InOut () () Default (Integer 4 [(() ()) (() ())]) Source Public Required .false.)}) accept_multidim_i32_array [(Var 2 xi32)] [(= (Var 2 _lpython_return_variable) (ArrayItem (Var 2 xi32) [(() (IntegerConstant 0 (Integer 4 [])) ()) (() (IntegerConstant 0 (Integer 4 [])) ())] (Integer 4 []) ()) ()) (Return)] (Var 2 _lpython_return_variable) Source Public Implementation ()), accept_multidim_i64_array: (Function (SymbolTable 3 {_lpython_return_variable: (Variable 3 _lpython_return_variable ReturnVar () () Default (Integer 8 []) Source Public Required .false.), xi64: (Variable 3 xi64 InOut () () Default (Integer 8 [(() ()) (() ()) (() ())]) Source Public Required .false.)}) accept_multidim_i64_array [(Var 3 xi64)] [(= (Var 3 _lpython_return_variable) (ArrayItem (Var 3 xi64) [(() (IntegerConstant 9 (Integer 4 [])) ()) (() (IntegerConstant 9 (Integer 4 [])) ()) (() (IntegerConstant 9 (Integer 4 [])) ())] (Integer 8 []) ()) ()) (Return)] (Var 3 _lpython_return_variable) Source Public Implementation ()), declare_arrays: (Subroutine (SymbolTable 6 {ac32: (Variable 6 ac32 Local () () Default (Complex 4 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 3 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 5 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 4 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 5 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 99 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 98 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 99 (Integer 4 []))))]) Source Public Required .false.), ac64: (Variable 6 ac64 Local () () Default (Complex 8 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 10 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 13 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 12 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 13 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 11 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 10 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 11 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 16 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 15 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 16 (Integer 4 []))))]) Source Public Required .false.), af32: (Variable 6 af32 Local () () Default (Real 4 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 3 (Integer 4 []))))]) Source Public Required .false.), af64: (Variable 6 af64 Local () () Default (Real 8 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 10 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 4 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 3 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 4 (Integer 4 []))))]) Source Public Required .false.), ai32: (Variable 6 ai32 Local () () Default (Integer 4 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 3 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 3 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 2 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 3 (Integer 4 []))))]) Source Public Required .false.), ai64: (Variable 6 ai64 Local () () Default (Integer 8 [((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 10 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 10 (Integer 4 [])))) ((IntegerConstant 0 (Integer 4 [])) (IntegerBinOp (IntegerBinOp (IntegerBinOp (IntegerConstant 10 (Integer 4 [])) Sub (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 9 (Integer 4 []))) Sub (IntegerConstant 0 (Integer 4 [])) (Integer 4 []) ()) Add (IntegerConstant 1 (Integer 4 [])) (Integer 4 []) (IntegerConstant 10 (Integer 4 []))))]) Source Public Required .false.)}) declare_arrays [] [(Print () [(FunctionCall 1 accept_multidim_i32_array () [((Var 6 ai32))] (Integer 4 []) () ())] () ()) (Print () [(FunctionCall 1 accept_multidim_i64_array () [((Var 6 ai64))] (Integer 8 []) () ())] () ()) (Print () [(FunctionCall 1 accept_multidim_f32_array () [((Var 6 af32))] (Real 4 []) () ())] () ()) (Print () [(FunctionCall 1 accept_multidim_f64_array () [((Var 6 af64))] (Real 8 []) () ())] () ())] Source Public Implementation () .false. .false.), main_program: (Program (SymbolTable 7 {}) main_program [] [(SubroutineCall 1 _lpython_main_program () [] ())])}) [])
6 changes: 1 addition & 5 deletions tests/reference/c-expr_12-93c7780.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "c-expr_12-93c7780.stdout",
<<<<<<< HEAD
"stdout_hash": "4f19d7165cd3881588f4b1e40f11e8092e4483155ac00cb5e61e3371",
=======
"stdout_hash": "15e70688598c75ec10b754b7d379cdbcc60ba46bd0b2eb44c1a69b80",
>>>>>>> main
"stdout_hash": "de298d7587b0be05a2a4c826c53f8339d5a331b019316c4a725a2582",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down

0 comments on commit ca4a002

Please sign in to comment.