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

泛型函数中使用值为null的成员变量对out参数赋值之后,再次对out参数赋值会导致解析器越界异常 #705

Closed
HoseaJiang opened this issue Jun 6, 2022 · 0 comments

Comments

@HoseaJiang
Copy link

Describe the bug
A clear and concise description of what the bug is.
泛型函数中使用值为null的成员变量对out参数赋值之后,再次对out参数赋值会导致解析器越界异常

To Reproduce
Steps to reproduce the behavior:
请描述重现步骤或上下文
class TestClass
{
public TestClass()
{
t = s++;
}
public int t;
static int s = 1;
}
//如果TestClass2也会有一样的异常
class TestClass2
{
public TestClass2()
{
p = null;
//非null就不会有问题
//p = new TestClass();
}
public bool TryGetObject(out T res) where T : TestClass, new()
{
//用局部变量中转没问题
//var tmp = p as T;
//res = null;
//res = tmp;
//这一句现在没什么用(比如用来if判断)但没有这一句不会报错。
res = p as T;
res = new T();//这里解析器越界异常
//res = p as T;//这样也会解析器越界异常
UnityEngine.Debug.Log("!!! new T");
return true;
}
TestClass p;
}

Expected behavior
A clear and concise description of what you expected to happen.
正常执行返回

Unity Version
Please fill in the version of Unity you're currently using
2020.3.33

ILRuntime Version
Please fill in the version of ILRuntime you're currently using(package version or git commit hash or repository download date)
最新

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant