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

Improve decompilation of Decimal type numeric literals ("m"-suffixed) #118

Open
stephen-swensen opened this issue Oct 20, 2015 · 2 comments
Labels
enhancement help wanted planned Indicates a feature or bug is planned for inclusion in a future release Priority-Low

Comments

@stephen-swensen
Copy link
Contributor

stephen-swensen commented Oct 20, 2015

F# > 4.0 quotes literal decimals in an odd way compared to other numeric literals such that it confuses the decompiler:

> <@ 2.3m @>;;
val it : Quotations.Expr<decimal> =
  Call (None, MakeDecimal,
      [Value (23), Value (0), Value (0), Value (false), Value (1uy)])
    {CustomAttributes = [NewTuple (Value ("DebugRange"),
          NewTuple (Value ("stdin"), Value (7), Value (3), Value (7), Value (7)))];
     Raw = ...;
     Type = System.Decimal;}
> unquote <@ 2.3m @>;;
val it : UnquotedExpression = 
23.[0, 0, false, 1uy]
2.3M
@stephen-swensen
Copy link
Contributor Author

The problem is that literal decimals are captured as a call to IntrinsicFunctions.MakeDecimal which matches this pattern generally used for arrays forms:

| P.Call(None, mi, target::args) when mi.DeclaringType.Name = "IntrinsicFunctions" -> //e.g. GetChar, GetArray, GetArray2D
https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/languageprimitives.intrinsicfunctions-module-%5Bfsharp%5D

We need to somehow evaluate this before decompiling, without doubling up in reduction steps.

@stephen-swensen stephen-swensen added the planned Indicates a feature or bug is planned for inclusion in a future release label Oct 27, 2020
@stephen-swensen
Copy link
Contributor Author

It looks like bigint literals have some issues too with regard to reduction

> test <@ 3I = 2I @>;;

Test failed:

3I = 2I
3 = 2
false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted planned Indicates a feature or bug is planned for inclusion in a future release Priority-Low
Projects
None yet
Development

No branches or pull requests

1 participant