Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Unions with 4 or more cases silently fail to utilize UseNullAsTrueValue. #510

Description

@bryanedds

Repro. case in F# 4.4.0.0 -

[<CompilationRepresentation (CompilationRepresentationFlags.UseNullAsTrueValue)>]
type T = A | B of int | C of int | D of int;;
A;;

In F# interactive, here you'll see that A is a proper value, which is not desired.

[<CompilationRepresentation (CompilationRepresentationFlags.UseNullAsTrueValue)>]
type T = A | B of int | C of int;;
A;;

In F# interactive, here you'll see that A is a null, which is desired.

Would be a nice optimization to have this work in general. Barring that fix, a warning or error about this missing functionality might be in order.

Cheers!

Activity

  1. enricosada commented on Nov 2, 2015

    @enricosada
    Contributor

    hi @bryanedds , this repo is for cross platoform packaing ( see http://fsharp.github.io/2014/06/18/fsharp-contributions.html for a guide) can you create or move this issue to Microsoft/visualfsharp repository?

    About this issue, there is a constant UnionReprDecisions.TaggingThresholdFixedConstant = 4, below this value the UseNullAsTrueValue is applied.

    This is used here

    I dont know the history about of this decision, @dsyme ? we need to add a warning (error?) or remove this check?

    There is already an error if the attribute cannot be applied, but the UnionReprDecisions.OptimizeAlternativeToNull is not aligned with CanHaveUseNullAsTrueValueAttribute, the only difference is this check where the constant TaggingThresholdFixedConstant is evaluated

  2. bryanedds commented on Nov 4, 2015

    @bryanedds
    Author

    Issue moved to - dotnet/fsharp#711

  3. added a commit that references this issue on Dec 2, 2015
    dd8252e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions