Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
UInt32 literals are typed as Int32 when used as enum values #194
Then, shouldn't my example break compilation? As a programmer, if I take care of defining a literal with a trailing "_u32" it's likely that my intent is for A to end up being a UInt32.
If that's not supported by the language I'd rather have it pointed out by the compiler than just silently typed to Int32.
The compiler exception could even do the same as you did: suggest having the enum extend UInt32 if that's what the programmer wants to achieve. In that case, I'd also expect to be warned if I assign something other than a UInt32 literal.
hi, I'm trying to solve this issue, I did the test and implementation, they are ok (at least I think so), but need to define some things like, on src/time/time.cr we have an enum like:
enum Kind : Int64 Unspecified = 0 Utc = 1 Local = 2 end
According to this issue, should break unless defined like:
enum Kind : Int64 Unspecified = 0_i64 Utc = 1_i64 Local = 2_i64 end
another possible solution is to raise the exception only when
Opened PR to make easier to discuss
referenced this issue
Jun 1, 2016
@fernandes No, it should not break, it should work. The idea of writing
The case you fixed is important, though, because it's unexpected that