From 55cd406eebf59718eec0eff95997579b26af8f5a Mon Sep 17 00:00:00 2001 From: Smit-create Date: Tue, 5 Apr 2022 20:23:13 +0530 Subject: [PATCH] Use function call floor div --- src/lpython/semantics/python_ast_to_asr.cpp | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index af99ec6f1d..d61cf7ca7f 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -727,19 +727,22 @@ class CommonVisitor : public AST::BaseVisitor { al, right->base.loc, right, ASR::cast_kindType::IntegerToReal, dest_type, value)); } - ASR::symbol_t *fn_div = resolve_intrinsic_function(loc, "_lpython_floordiv"); - Vec args; - args.reserve(al, 1); - ASR::call_arg_t arg1, arg2; - arg1.loc = left->base.loc; - arg2.loc = right->base.loc; - arg1.m_value = left; - arg2.m_value = right; - args.push_back(al, arg1); - args.push_back(al, arg2); - tmp = make_call_helper(al, fn_div, current_scope, args, "_lpython_floordiv", loc); - return; + left = implicitcast_helper(ASRUtils::expr_type(right), left); + right = implicitcast_helper(ASRUtils::expr_type(left), right); + dest_type = ASRUtils::expr_type(left); } + ASR::symbol_t *fn_div = resolve_intrinsic_function(loc, "_lpython_floordiv"); + Vec args; + args.reserve(al, 1); + ASR::call_arg_t arg1, arg2; + arg1.loc = left->base.loc; + arg2.loc = right->base.loc; + arg1.m_value = left; + arg2.m_value = right; + args.push_back(al, arg1); + args.push_back(al, arg2); + tmp = make_call_helper(al, fn_div, current_scope, args, "_lpython_floordiv", loc); + return; } else { // real divison in python using (`/`) dest_type = ASRUtils::TYPE(ASR::make_Real_t(al, loc,