Skip to content
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

Conversion from Signed Integer Type / ja:符号付き整数型からの変換 #48

Open
ikuko opened this issue Jul 13, 2020 · 2 comments
Labels
blocked-vrc Blocked due to missing underlying functionality or relying on some underspecified system bug Something isn't working

Comments

@ikuko
Copy link

ikuko commented Jul 13, 2020

Describe the bug in detail:
The behavior of C# and U# is different when you do an explicit cast.
(ja: ) 明示的キャストを行った際にC#とU#で動作が異なります

Provide steps/code to reproduce the bug:
C# or U# code
(ja:) C#もしくはU#のコード

int value = -1;
Debug.Log($"value: {value}");
var converted = (uint)value;// This is where Udon stops working!
Debug.Log($"converted: {converted}");

An excerpt of the problematic part of UAssembly
(ja:) 問題のある部分のUAssemblyを抜粋

 # var converted = (uint)value;
PUSH, __2_value_Int32
PUSH, __2_intnl_SystemUInt32
EXTERN, "SystemConvert.__ToUInt32__SystemInt32__SystemUInt32"
PUSH, __2_intnl_SystemUInt32
PUSH, __2_converted_UInt32
COPY

Expected behavior:
If you follow C#, this U# code will be displayed in the console like this
(ja:) C#に従うならばこのU#コードはコンソールに以下のように表示します

value: -1
converted: 4294967295

Explicit casts to the form of using methods such as Convert.ToUInt32 It is due to compiling.
However, due to the way U# and Udon work, this may be an inevitable glitch.
I wish there is a good solution, but I think it's difficult to fix.
It would be better to present it as a specification in README.
(ja:)
明示的キャストをConvert.ToUInt32のようなメソッドを使用する形にコンパイルすることが原因です。
しかしながらU#とUdonの仕組み上これは仕方ない不具合かもしれません。
何かしら良い解決策があれば良いのですが、修正は難しいと思います。
READMEなどで仕様として提示すると良いでしょう。

@ikuko ikuko added the bug Something isn't working label Jul 13, 2020
@MerlinVR MerlinVR added the blocked-vrc Blocked due to missing underlying functionality or relying on some underspecified system label Jul 13, 2020
@MerlinVR
Copy link
Owner

Yeah this is known thing that I can't do much about without adding a chunk of overhead to numeric casts since Udon doesn't provide a way to cast for "real" right now and Convert functions are checked. I'll add a note about this to the README, but this behavior will change to be unchecked when VRC implements proper numeric casting.

Some relevant cannys for this:
https://vrchat.canny.io/vrchat-udon-closed-alpha-feedback/p/provide-an-instruction-that-does-not-automatically-reassign-the-strongbox-type-w
https://vrchat.canny.io/vrchat-udon-closed-alpha-feedback/p/cast-nodes

@ikuko
Copy link
Author

ikuko commented Jul 13, 2020

Thanks, I voted for canny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked-vrc Blocked due to missing underlying functionality or relying on some underspecified system bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants