-
Notifications
You must be signed in to change notification settings - Fork 170
Imports Fails When Import From Files: Links To #1611 Issue #1612
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
Comments
I think this issue is due to us not supporting global statements in a module that is being imported. A workaround until we fix it is to put all such statements into a function, say, |
This is fixed in the See, the generated code. I have added print statements to verify the execution. C code
#include <complex.h>
#include <inttypes.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <lfortran_intrinsics.h>
#define ASSERT(cond) \
{ \
if (!(cond)) { \
printf("%s%s", "ASSERT failed: ", __FILE__); \
printf("%s%s", "\nfunction ", __func__); \
printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \
printf("%s%s", #cond, "\n"); \
exit(1); \
} \
}
#define ASSERT_MSG(cond, msg) \
{ \
if (!(cond)) { \
printf("%s%s", "ASSERT failed: ", __FILE__); \
printf("%s%s", "\nfunction ", __func__); \
printf("%s%d%s", "(), line number ", __LINE__, " at \n"); \
printf("%s%s", #cond, "\n"); \
printf("%s", "ERROR MESSAGE:\n"); \
printf("%s%s", msg, "\n"); \
exit(1); \
} \
}
struct dimension_descriptor
{
int32_t lower_bound, length;
};
// Implementations
double __lpython_overloaded_0__pow(int32_t x, int32_t y)
{
double _lpython_return_variable;
_lpython_return_variable = (double)(pow(x, y));
return _lpython_return_variable;
}
float _lfortran_caimag(float complex x);
double _lfortran_zaimag(double complex x);
void test_pow()
{
int32_t a;
a = (int32_t)(__lpython_overloaded_0__pow(2, 2));
}
int32_t test_pow_1(int32_t a, int32_t b)
{
int32_t _lpython_return_variable;
int32_t res;
res = (int32_t)(__lpython_overloaded_0__pow(a, b));
_lpython_return_variable = res;
return _lpython_return_variable;
}
void main0()
{
int32_t c;
test_pow();
printf("%s\n", "in module expr7");
c = test_pow_1(1, 2);
}
void global_statements()
{
main0();
}
void _xx_lcompilers_changed_main_xx()
{
printf("%s\n", "in module bar");
test_pow();
}
void _lpython_main_program()
{
global_statements();
_xx_lcompilers_changed_main_xx();
}
int main(int argc, char* argv[])
{
_lpython_main_program();
return 0;
} Can you please verify @ronnuriel? Thanks! |
Imports from import file fails
Lets create bar.py (bar.py is in the same directory as expr7)
bar.py:
expr7.py:
*** Please notice main0() call
Run:
lpython --show-c -I . bar.py
Getting the following error
The text was updated successfully, but these errors were encountered: