lpython icon indicating copy to clipboard operation
lpython copied to clipboard

Incorrect parsing of ``INT64_MAX`` and ``INT64_MIN``

Open czgdp1807 opened this issue 3 years ago • 1 comments

Example

from ltypes import i64

negu: i64 = i64(-9223372036854775808)
posu: i64 = i64(9223372036854775808)

AST

(Module [(ImportFrom ltypes [(i64 ())] 0) (AnnAssign (Name negu Store) (Name i64 Load) (Call (Name i64 Load) [(UnaryOp USub (ConstantInt 4611686019631184192 ()))] []) 1) (AnnAssign (Name posu Store) (Name i64 Load) (Call (Name i64 Load) [(ConstantInt 4611686019631184322 ())] []) 1)] [])

9223372036854775808 and -9223372036854775808 are getting parsed to 4611686019631184192.

czgdp1807 avatar Dec 12 '22 06:12 czgdp1807

4611686019631184192 is the pointer to the very large number, which should have been handled later on (AST->ASR, ...). This was followed in LFortran before. But, I don't know whether LFortran follows the same now. I will look into this and report back.

Thirumalai-Shaktivel avatar Dec 31 '22 09:12 Thirumalai-Shaktivel