Type inference of integer literals: inconsistency with the reference #41060
Labels
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
A-inference
Area: Type inference
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
The reference currently says the following for integer literals
This does however not work for some inherent methods of signed integer types:
As you can see,
z
is under-constrained in this case. The compiler does the right thing and defaults to typei32
, so calling the trait methodwhat_type()
works.If you uncomment the inherent method call to
is_positive()
,z
still is under-constrained in pretty much the same way as before, however, the compiler fails to default toi32
and instead printsAlso note that the reference says
But the following example show that the order of statements is important:
I think floating-point literals have the same issue, but I haven't checked.
Issue #39255 and issue #40985 may be related.
The text was updated successfully, but these errors were encountered: