Skip to content

Attributes are not included in SynExceptionDefnRepr / SynExceptionSig #12434

@nojaf

Description

@nojaf

While looking into fsprojects/fantomas#1974, I noticed that range of SynExceptionSig / SynExceptionDefnRepr does not include the atrributes.

Repro steps

code:

module internal FSharp.Compiler.ParseHelpers

open FSharp.Compiler.AbstractIL.IL

/// The error raised by the parse_error_rich function, which is called by the parser engine
[<NoEquality; NoComparison>]
exception SyntaxError of obj * range: range

AST:

SigFile
  (ParsedSigFileInput
     ("tmp.fsi", QualifiedNameOfFile FSharp.Compiler.ParseHelpers, [], [],
      [SynModuleOrNamespaceSig
         ([FSharp; Compiler; ParseHelpers], false, NamedModule,
          [Open
             (ModuleOrNamespace
                ([FSharp; Compiler; AbstractIL; IL], tmp.fsi (3,5--3,34)),
              tmp.fsi (3,0--3,34));
           Exception
             (SynExceptionSig
                (SynExceptionDefnRepr
                   ([{ Attributes =
                        [{ TypeName = LongIdentWithDots ([NoEquality], [])
                           ArgExpr = Const (Unit, tmp.fsi (6,2--6,12))
                           Target = None
                           AppliesToGetterAndSetter = false
                           Range = tmp.fsi (6,2--6,12) };
                         { TypeName = LongIdentWithDots ([NoComparison], [])
                           ArgExpr = Const (Unit, tmp.fsi (6,14--6,26))
                           Target = None
                           AppliesToGetterAndSetter = false
                           Range = tmp.fsi (6,14--6,26) }]
                       Range = tmp.fsi (6,0--6,28) }],
                    SynUnionCase
                      ([], SyntaxError,
                       Fields
                         [SynField
                            ([], false, None,
                             LongIdent (LongIdentWithDots ([obj], [])), false,
                             PreXmlDocEmpty, None, tmp.fsi (7,25--7,28));
                          SynField
                            ([], false, Some range,
                             LongIdent (LongIdentWithDots ([range], [])), false,
                             PreXmlDocEmpty, None, tmp.fsi (7,31--7,43))],
                       PreXmlDocEmpty, None, tmp.fsi (7,10--7,43)), None,
                    PreXmlDoc ((7,9), FSharp.Compiler.Xml.XmlDocCollector), None,
                    tmp.fsi (7,0--7,43)), [], tmp.fsi (7,0--8,0)),
              tmp.fsi (7,0--8,0))],
          PreXmlDoc ((1,6), FSharp.Compiler.Xml.XmlDocCollector), [],
          Some Internal, tmp.fsi (1,0--8,0))]))

online tool

Expected behaviour

SynExceptionDefnRepr and SynExceptionSig go from line 6 to 7.

Actual behaviour

Only line 7 is included in the range.
Also, if you add even more blank lines under the Exception, the range expands to the end of the file.
That doesn't seem correct as well.

Known workarounds

The range could be calculated.

Related information

Provide any related information (optional):

FCS 41
related: #11481

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