-
-
Notifications
You must be signed in to change notification settings - Fork 191
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
Cannot cast from aliased type to type for user defined types #165
Comments
The statement type::UUID uuid; cannot in itself create the error involving guid since guid is never mentioned. Please post the part of the code that tries to cast uuid to guid. But in general it is impossible to cast from a non builtin type to a different non-builtin type regardless. You can place both pattersn on the same data to interpret it two different ways. |
Simply displaying the value in the Pattern Data window leads to this error. Otherwise you can also use
Output:
I am not explicitly casting any data. It's an implicit cast that's probably done by the ImHex-Patterns/includes/type/guid.pat Line 21 in c0c117a
The docs implied that I could use UUID as an alias for GUID. |
I was wrong in my assumption that UUID and GUID were two different structs. Being an alias allows you to use one in place of the other. The error is caused by the argument of the format function being 'GUID guid' instead of what normally should be 'auto guid' as this change fixes the error, but I am not sure if the error should exist at all. |
So I checked this and the problem is not just for UUID and GUID or even types with function attributes. The problem is much more general so the title of this issue should be changed accordingly. When you create an alias for a type with using the alias and the type both represent the same pl type and casting between them should be possible. This works for builtin types s32 test @ 0;
using int = s32;
int test2 = test; // works ok However a similar check using user defined types give a casting operation error. A simplest case example is struct A {
u8 byte;
};
A a @ 0;
using B=A;
B b1=a; //error cannot cast from A to B Could you please change the title of this issue to read
|
Thank you for checking the issue. I changed the title and description of the issue accordingly. |
This issue was edited after finding out that it has a wider scope than initially assumed. When you create an alias for a type with
using
the alias and the type both represent the same pl type and casting between them should be possible. This works for builtin typesHowever a similar check using user defined types give a casting operation error. A simplest case example is
I initially found this issue by trying to parse a uuid like so:
When doing so, I recieve the error
[E0004]: Type error. Cannot cast from type 'type::UUID' to type 'type::GUID'
when displaying the UUID in the Pattern Data or when printing the variable withstd::print
. This is probably because theformat_guid
function expects a struct of type GUID and doesn't know anything about UUID.The issue can be reproduced with this pattern.
If my assumption is correct, the issue does not only affect UUIDs but all types with function attributes.
The text was updated successfully, but these errors were encountered: