lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.5k stars 163 forks source link

MSVC gives different outputs compared to WSL build, Linux/Mac OS ? #1593

Open faze-geek opened 1 year ago

faze-geek commented 1 year ago

I have come across some instances where I felt that the MSVC build set up gives different outputs to other machines. One such case can be seen in #1590 .

Snippet -

def fun():
    x : dict[i32, i32] = {1: 2}
    print(x[1])

    y : dict[str, i32]
    y = {"apple": 1}
    print(y["apple"])

fun()

On my MSVC windows setup -

(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
code generation error: Variable type not supported 12
 --> try.py:5:5
  |
5 |     y : dict[str, i32]
  |     ^^^^^^^^^^^^^^^^^^

On my WSL with windows setup -

(lp) faze-geek@DESKTOP-497JDCU:~/lpython/lpython$ ./src/bin/lpython try.py
2
1

@Smit-create @certik Any possible reasons why this might be happening. We should look into this.

faze-geek commented 1 year ago

Here is another case where even after the pr fixing #1524 MSVC does not generate the correct result. Look at the comments - https://github.com/lcompilers/lpython/issues/1524#issuecomment-1434714762 . Smit was not able to reproduce these results on his main if I recall correctly.

harshsingh-24 commented 1 year ago

Even I am facing the same issue as stated above. I am also working with the MSVC compiler on Windows. I raised an issue too.

Thirumalai-Shaktivel commented 1 year ago

@faze-geek, Can you please verify that both Windows and WSL generate the same ASR?

Thirumalai-Shaktivel commented 1 year ago

This Error message should only be shown for Global statements, but why does it show for the variables inside a function? I don't know whether this error was introduced after this PR: https://github.com/lcompilers/lpython/pull/1491 was merged. We need to investigate what's going on here.

certik commented 1 year ago

We'll have to investigate why MSVC behaves differently.