Skip to content

Attribute range is not included in extern declaration #11734

@nojaf

Description

@nojaf

Consider the following code:

[<DllImport("oleacc.dll")>]
extern int AccessibleChildren()

Matching AST

ImplFile
  (ParsedImplFileInput
     ("tmp.fsx", true, QualifiedNameOfFile Tmp$fsx, [], [],
      [SynModuleOrNamespace
         ([Tmp], false, AnonModule,
          [Let
             (false,
              [SynBinding
                 (None, Normal, false, false,
                  [{ Attributes =
                      [{ TypeName = LongIdentWithDots ([DllImport], [])
                         ArgExpr =
                          Paren
                            (Const
                               (String
                                  ("oleacc.dll", Regular,
                                   tmp.fsx (1,12--1,24) IsSynthetic=false),
                                tmp.fsx (1,12--1,24) IsSynthetic=false),
                             tmp.fsx (1,11--1,12) IsSynthetic=false,
                             Some tmp.fsx (1,24--1,25) IsSynthetic=false,
                             tmp.fsx (1,11--1,25) IsSynthetic=false)
                         Target = None
                         AppliesToGetterAndSetter = false
                         Range = tmp.fsx (1,2--1,11) IsSynthetic=false }]
                     Range = tmp.fsx (1,0--1,27) IsSynthetic=false }],
                  PreXmlDoc ((2,6), FSharp.Compiler.Xml.XmlDocCollector),
                  SynValData
                    (None, SynValInfo ([[]], SynArgInfo ([], false, None)), None),
                  LongIdent
                    (LongIdentWithDots ([AccessibleChildren], []), None,
                     Some (SynValTyparDecls ([], false, [])),
                     Pats
                       [Tuple
                          (false, [], tmp.fsx (2,29--2,30) IsSynthetic=false)],
                     None, tmp.fsx (2,11--2,29) IsSynthetic=false),
                  Some
                    (SynBindingReturnInfo
                       (App
                          (LongIdent (LongIdentWithDots ([int], [])), None, [],
                           [], None, false,
                           tmp.fsx (2,7--2,10) IsSynthetic=false),
                        tmp.fsx (2,7--2,10) IsSynthetic=false, [])),
                  Typed
                    (App
                       (NonAtomic, false, Ident failwith,
                        Const
                          (String
                             ("extern was not given a DllImport attribute",
                              Regular, tmp.fsx (2,30--2,31) IsSynthetic=false),
                           tmp.fsx (2,30--2,31) IsSynthetic=false),
                        tmp.fsx (2,0--2,31) IsSynthetic=false),
                     App
                       (LongIdent (LongIdentWithDots ([int], [])), None, [], [],
                        None, false, tmp.fsx (2,7--2,10) IsSynthetic=false),
                     tmp.fsx (2,0--2,31) IsSynthetic=false),
                  tmp.fsx (2,0--2,31) IsSynthetic=false, NoneAtInvisible)],
              tmp.fsx (2,0--2,31) IsSynthetic=false)], PreXmlDocEmpty, [], None,
          tmp.fsx (1,0--2,31) IsSynthetic=false)], (true, true)))

Expected behavior

I would expect the range of the SynModuleDecl.Let and SynBinding to include the range of the attribute.

Actual behavior

Range is 2.0 - 2.31, not starting from 1.0 as the attribute does.

Known workarounds

Create a custom range based on other elements.

Related information

Provide any related information (optional):

  • Editing Tools (e.g. Visual Studio Version, Visual Studio): FCS 40.

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