Skip to content

static extern inside a type loses static #3515

Closed

Description

@nojaf

Issue created from fantomas-online

Code

type T =
    static extern int F(int x)

Result

type T =
    extern int F(int x)

Problem description

Inside a type, static extern loses its static: the result parses, but it is a different declaration, since the syntax tree's static flag goes from true to false.

The attribute does not matter: [<DllImport("user32.dll")>] above the member gives the same result, and so does a type with members besides the extern.

Fails on 8.0.6, 7.0.5 and main. #1214 was about an extern inside a type too, and is closed.

Found while writing a snapshot case for MemberDefn.ExternBinding in #3512.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

Options

Fantomas main branch at 2026-10-02T18:44:31Z - 8bf81a1

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

Activity

  1. added a commit that references this issue on Oct 7, 2026
    9dc78c1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions