Skip to content
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

WASM: Support const type #2296

Closed
Shaikh-Ubaid opened this issue Aug 24, 2023 · 0 comments · Fixed by #2297
Closed

WASM: Support const type #2296

Shaikh-Ubaid opened this issue Aug 24, 2023 · 0 comments · Fixed by #2297
Labels

Comments

@Shaikh-Ubaid
Copy link
Collaborator

Shaikh-Ubaid commented Aug 24, 2023

related #1485

$ cat integration_tests/const_01.py 
from lpython import Const, i32, i64, f32, f64

def test_const_variables():
    xci: Const[i32] = i32(0.0)
    xi: i32 = 0

    yci: Const[i64] = int(1)
    yi: i64 = int(1)

    xcf: Const[f32] = f32(2)
    xf: f32 = f32(2.0)

    ycf: Const[f64] = 3.0
    yf: f64 = 3.0

    print(xci, xi)
    print(yci, yi)
    print(xcf, xf)
    print(ycf, yf)

    assert xci == xi
    assert yci == yi
    assert xcf == xf
    assert ycf == yf

test_const_variables()
$ lpython_in_main integration_tests/const_01.py 
0 0
1 1
2.00000000e+00 2.00000000e+00
3.00000000000000000e+00 3.00000000000000000e+00
$ lpython_in_main integration_tests/const_01.py --backend wasm
warning: Unsupported variable type: real const
  --> integration_tests/const_01.py:10:5
   |
10 |     xcf: Const[f32] = f32(2)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^ Only integer, floats, logical and complex supported currently

warning: Unsupported variable type: integer const
 --> integration_tests/const_01.py:4:5
  |
4 |     xci: Const[i32] = i32(0.0)
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ Only integer, floats, logical and complex supported currently

warning: Unsupported variable type: real const
  --> integration_tests/const_01.py:13:5
   |
13 |     ycf: Const[f64] = 3.0
   |     ^^^^^^^^^^^^^^^^^^^^^ Only integer, floats, logical and complex supported currently

warning: Unsupported variable type: integer const
 --> integration_tests/const_01.py:7:5
  |
7 |     yci: Const[i64] = int(1)
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ Only integer, floats, logical and complex supported currently

code generation error: Only Integer, Float, Bool, Character, Complex variable types supported currently


Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that must be fixed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant