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

char and byte type can not be distinguished. #41

Closed
yindongfei opened this issue Apr 12, 2018 · 0 comments
Closed

char and byte type can not be distinguished. #41

yindongfei opened this issue Apr 12, 2018 · 0 comments

Comments

@yindongfei
Copy link

string s = "123";
var sb = new StringBuilder();
sb.Append(s[0]);
int x = int.Parse(sb.ToString()); // here x is not 1 but 31(ASCII)

when sb.Append(s[0]); s[0] is cast to byte by string:byte(), then int.Parse will consider it as a number type and get 31.

the problem is when c# call sb.Append(char c) and sb.Append(int x), c is just append at end of buffer but x will convert to string. but in lua, s[0] always return a number, and lua can not distinguish char and int here.

solution:
during transfor ast, type info can retrieve from roslyn in sb.Apppend(TYPE t), here type cast may needed when c# call ToString automatically.

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