-
Notifications
You must be signed in to change notification settings - Fork 789
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
Allow decimal constants #17769
Allow decimal constants #17769
Conversation
❗ Release notes required
|
@dotnet-policy-service agree |
Hi @esbenbjerre , thanks for this contribution.
|
Thanks @T-Gro. I'm still trying to codegen the cctor code. Would you prefer I convert it to draft until it's ready? |
Yeah, let's convert it to draft so it doesn't pop up on our triage radar |
@T-Gro I have a couple of questions regarding the test requirements.
|
For the C# interop, the test framework in "ComponentTests" suite can handle CsharpSource as well.
(or if curious, just look at more usages of the "CSharp" function. For pattern matching a decimal literal, the IL should contain:
For inspiration, look at tests which use the "verifyIL" function in the "ComponentTests" suite. I start such tests by writing a minimal F# sample, let the verification fail, and then copy relevant snippets of IL from the test output into the assertion list (that is assuming the IL looks good) |
3935cda
to
4ad236c
Compare
@T-Gro I'm getting namespace Interop
open Xunit
open FSharp.Test.Compiler
module ``TestDeleteMe`` =
[<Fact>]
let ``Instantiate F# decimal literal from C#`` () =
let FSLib =
FSharp """
namespace Interop.FS
module DecimalLiteral =
[<Literal>]
let x = 7m
""" |> withName "FSLib"
let app =
CSharp """
using System;
using Interop.FS;
public class C {
public Decimal y = DecimalLiteral.x;
}
""" |> withReferences [FSLib]
app
|> compile
|> shouldSucceed results in
|
I managed to solve it by adding |
99ce53c
to
8812aaf
Compare
I think this is worth a small RFC so we can track this later in the language spec. |
Yes, this will need an rfc |
Created RFC PR here fsharp/fslang-design#790 |
The intention of this PR is to add support for the use of the literal attribute on decimals.
Related fsharp/fslang-suggestions#847