Skip to content

Misleading extra error message when field declaration order differs between signature & implementation #20410

Description

@brianrourkeboll

Repro steps

Signature

type ResolvedConfig =
    {
        Config: FormatConfig
        Settings: ResolvedSetting list
        EditorConfigFiles: string list
        Problems: EditorConfigProblem list
    }

Implementation

type ResolvedConfig = // FS0313: The type definitions for type 'ResolvedConfig' in the signature and implementation are not compatible because the order of the fields is different in the signature and implementation
    {
        Config: FormatConfig
        EditorConfigFiles: string list // FS0193: The module contains the field     EditorConfigFiles: string list     but its signature specifies     Settings: ResolvedSetting list     The names differ
        Problems: EditorConfigProblem list
        Settings: ResolvedSetting list
    }

Expected behavior

FS0313 should be emitted on the type. (Record field declaration order matters, since it affects the order of ctor parameters.)

Actual behavior

FS0193 is also emitted for the first out-of-order field in the implementation. There is however a field Settings: ResolvedSetting list; it's just not at the same ordinal.

The message is not strictly wrong, but it is arguably misleading. Maybe we should include wording like "the names at this position differ" or something?

Known workarounds

N/A

Related information

Current main.

I happened to notice this when testing out record type spreads in Fantomas, but the extra error message happens for explicit field declarations as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions