Fix integer.create and fromstring type definitions#2540
Conversation
integer.create and fromstring type definitions
|
This change will require a separate flag. |
|
Can you share the motivation behind this change? |
|
|
While being the correct type in theory, I find this would make working with integers worse. For instance: local one = integer.create(1)
local two = integer.create(2)
integer.add(one, two) -- this would now be a type error |
If you know you're doing it right, you can typecast for zero runtime overhead: local one = integer.create(1) :: integerperhaps a magic type function could be added to
I think Also, maybe |
integer.createandinteger.fromstringcan return nil, but the embedded type definitions don't reflect that:The embedded definitions also mismatch the integer RFC, where they are both documented to return
integer?, and notinteger.Example program to demonstrate why this is a problem:
This program really needs to check that it's not adding nil numbers:
But the typechecker doesn't notice
After this change, the typechecker also gives a warning:
I don't expect this change will need a FFlag, as integers are still experimental, but I'll add one if requested