lcompilers / lpython

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

Interactive LPython delays the response or crashes #2807

Closed namannimmo10 closed 2 weeks ago

namannimmo10 commented 1 month ago

To reproduce,

(lp) namannimmo@srf lpython % lpython
>>> a: i32 = 10                                                                                                                                                                                      1,12  ]
>>> b: f64 = 20.                                                                                                                                                                                     1,13  ]
>>> a + b                                                                                                                                                                                            1,6   ]
semantic error: Type mismatch in binary operator; the types must be compatible
 --> input:1:1
  |
1 | a + b
  | ^   ^ type mismatch (i32 and f64)

Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues.
>>> a + i32(b)                                                                                                                                                                                       1,11  ]
30
>>> pow(a, i32(b))                                                                                                                                                                                   1,15  ]
2147483647
>>> a ** i32(b)                                                                                                                                                                                      1,12  ]
2147483647
>>> a: i32                                                                                                                                                                                           1,7   ]
style suggestion: Could have used '**' instead of 'pow'
 --> input:1:1
  |
1 | a: i32
  | ^^ '**' could be used instead

semantic error: Symbol is already declared in the same scope
 --> input:1:1
  |
1 | a: i32
  | ~~~~~~~~~~~ original declaration
  |
1 | a: i32
  | ^^^^^^ redeclaration

The suggestion was delayed in the case above, but it might crash, too.