Skip to content

New case for FS3186: An error occurred while reading the F# metadata node #1626

@dgchurchill

Description

@dgchurchill

This is a new case that triggers the "FS3186: An error occurred while reading the F# metadata node..." error previously reported in #592 and #631. It's unlikely to be worth fixing this case itself but I'm reporting it in case it helps identify other corner-cases in the metadata generation.

Repro steps

The error can be triggered by compiling an assembly with a method that has a [<DefaultParameterValue(null)>] attribute on one of its parameters, and then referencing that assembly.

e.g.

Compile this:

namespace Namespace1
open System.Runtime.InteropServices

type Interface1 = 
    abstract Method1 : [<DefaultParameterValue(null)>] arg1 : obj -> unit

Then reference it in F# Interactive:

Microsoft (R) F# Interactive version 14.0.23413.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> #r "Bad.dll";;


unknown(1,1): warning FS3186: An error occurred while reading the F# metadata node at position 0 in table 'itypars' of assembly 'Bad, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The node had no matching declaration. Please report this warning. You may need to recompile the F# assembly you are using.

--> Referenced 'Bad.dll'

Expected behavior

The compiler should either fail when compiling [<DefaultParameterValue(null)>] or produce correct metadata. However also see #96 -- DefaultParameterValue is not actually supported by the F# compiler. So no one can be using this, and in this case could use the [<Optional>] attribute and deal with Type.Missing anyway.

Related information

Tested using Microsoft (R) F# Compiler version 14.0.23413.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions