-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow integer expressions and sizeof() as part of type notation #5427
Comments
Having a nice error message on that StaticArray use instead of syntax error could also close #4238 |
We can't allow I wouldn't like to support general expressions there too. Right now the only use case for integer types in generic types is StaticArray. It's a strange case. And using numbers or computed constants is enough for now. |
@asterite the request is for a special case to allow |
I just stepped on this issue, with the following code: (which is basically the same issue, but with non-primitive types) struct Bar(T)
@var = StaticArray(UInt8, instance_sizeof(T)).new 0_u8
end
class MyClass
@field = 42
end
puts Bar(MyClass).new Basically I want a type It should be quite possible, as |
The discussion about arithmetic expressions continues in #11759 |
Hi,
Next to #5426 I also came across that you can't do calculations inside type notations. You also can't use
sizeof
.sizeof
on arbitrary types may be too hard, but it could be allowed for primitive types.Depending on where I get different errors, including a compiler bug message:
Another edge case was using a constant with a calculation with sizeof():
Thanks
The text was updated successfully, but these errors were encountered: