Skip to content

Fix tuple arguments type in function #1349

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

Merged
merged 3 commits into from
Dec 4, 2022
Merged
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
19 changes: 18 additions & 1 deletion integration_tests/test_tuple_02.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,21 @@ def f():
assert t1[3] == complex(55, 55)
print(t1[0], t1[1], t1[2], t1[3])

f()

def g_check(x: tuple[i32, i32], y: tuple[i32, i32]) -> bool:
return x[0] == y[0]

def test_issue_1348():
a11: tuple[i32, i32]
b11: tuple[i32, i32]
a11 = (1, 2)
b11 = (1, 2)
assert g_check(a11, b11)


def check():
f()
test_issue_1348()


check()
15 changes: 1 addition & 14 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2973,20 +2973,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
break;
}
case (ASR::ttypeType::Tuple) : {
ASR::Tuple_t* asr_tuple = ASR::down_cast<ASR::Tuple_t>(asr_type);
std::string type_code = ASRUtils::get_type_code(asr_tuple->m_type,
asr_tuple->n_type);
std::vector<llvm::Type*> llvm_el_types;
for( size_t i = 0; i < asr_tuple->n_type; i++ ) {
bool is_local_array_type = false;
int local_n_dims = 0;
int local_a_kind = -1;
ASR::storage_typeType local_m_storage = ASR::storage_typeType::Default;
llvm_el_types.push_back(get_arg_type_from_ttype_t(asr_tuple->m_type[i], m_abi,
arg_m_abi, local_m_storage, arg_m_value_attr, local_n_dims,
local_a_kind, is_local_array_type, ASRUtils::intent_local));
}
type = tuple_api->get_tuple_type(type_code, llvm_el_types)->getPointerTo();
type = get_type_from_ttype_t_util(asr_type)->getPointerTo();
break;
}
case (ASR::ttypeType::List) : {
Expand Down