Skip to content

Possible regression in 3.x #735

Description

@rdanitz

We're hitting a regression when migrating our codebase from 2.16.6 to 3.3.3.

This is a minimal repro in C# that fails already at generation time:

using FsCheck;
using FsCheck.Fluent;
using FsCheck.Xunit;

namespace FsCheckRepro;

public abstract record Foo(string s);

public record Bar(string s, int n) : Foo(s);

public class Test
{
    [Property]
    public Property Prop(Bar message) => (message.s == (message as Foo)!.s).ToProperty();
}

Error: System.InvalidCastException : Unable to cast object of type 'System.Int32' to type 'System.String'.

We use a lot of Discriminated Unions in our codebase and rely on automatic generation of records. Writing all generators by hand for the derived records is possible, but tedious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions