Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute range is not included in extern declaration #11734

Closed
nojaf opened this issue Jun 26, 2021 · 0 comments · Fixed by #11736
Closed

Attribute range is not included in extern declaration #11734

nojaf opened this issue Jun 26, 2021 · 0 comments · Fixed by #11736

Comments

@nojaf
Copy link
Contributor

nojaf commented Jun 26, 2021

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant