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

int64 parse error #33

Open
zgsxtyzgd opened this issue Apr 23, 2020 · 4 comments
Open

int64 parse error #33

zgsxtyzgd opened this issue Apr 23, 2020 · 4 comments

Comments

@zgsxtyzgd
Copy link

in "Irony\Parsing\Terminals\NumberLiteral.cs" 275 row
case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: if (details.Value == null) //if it is not done yet TryConvertToLong(details, typeCode == TypeCode.UInt64); //try to convert to Long/Ulong and place the result into details.Value field; if(TryCastToIntegerType(typeCode, details)) //now try to cast the ULong value to the target type return true; break;
Proposed changes to :
case TypeCode.Int32: case TypeCode.UInt32: case TypeCode.Int64: case TypeCode.UInt64: if (details.Value == null) //if it is not done yet if (TryConvertToLong(details, typeCode == TypeCode.UInt64)) //try to convert to Long/Ulong and place the result into details.Value field; return true; if(TryCastToIntegerType(typeCode, details)) //now try to cast the ULong value to the target type return true; break;

@rivantsov
Copy link
Contributor

well.. not sure.. comments there explain it's necessary to do the last conversion. Did you run into an error or failed conversion? pls provide more details.
Also pls check that code you post is formatted properly with line breaks, it's quite difficult to reformat it back

@zgsxtyzgd
Copy link
Author

declare var number = new NumberLiteral("number");
You can try to deal with the number -1000000000000000.
in "Irony\Parsing\Terminals\NumberLiteral.cs" 276 row:
Suppose have a number - 1000000000000000 if you call TryConvertToLong(details, typeCode == TypeCode.UInt64); returns true, you should not call call TryCastToIntegerType(typeCode, details) 277 rows, because convert to an Int32 trigger an error.
TryConvertToLong(details, typeCode == TypeCode.UInt64); returns TRUE is equivalent to being dumped in the current Code

@rivantsov
Copy link
Contributor

I see... will fix it in next patch,

Al-Dyachkov added a commit to Al-Dyachkov/Irony that referenced this issue Dec 25, 2023
@Al-Dyachkov
Copy link

For anyone having same issues : this can be solved by additional NumberLiteral setup, example can be found here :
https://github.com/IronyProject/Irony/blob/master/Irony/Parsing/Terminals/TerminalFactory.cs#L54

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

3 participants