erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.69k stars 55 forks source link

Cannot declare `Ratio` type #215

Open GreasySlug opened 2 years ago

GreasySlug commented 2 years ago

Describe the bug?

Declaring a Ratio type will convert it to a Float type instead of the Ratio type

Reproducible code

1.0

Expected result

1.0 (: {Ratio(1.0), })

Actual result

1.0 (: {1.0f, })

Additional context

Therefore, a declaration with a type will result in an error

>>> a: Ratio = 1.0
Error[#0052]: File <stdin>, line 1, in <module>
1│ a: Ratio = 1.0
   ^
TypeError: the type of a is mismatched:
expected:  Ratio
but found: {1.0f, }

Erg version

0.5.9

Python version

3.10.6

os

windows10