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

Add trivia information to SynConst.Measure #15614

Merged
merged 16 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ let ForNewConstructors tcSink (env: TcEnv) mObjTy methodName meths =
/// Typecheck rational constant terms in units-of-measure exponents
let rec TcSynRationalConst c =
match c with
| SynRationalConst.Integer i -> intToRational i
| SynRationalConst.Integer(value = i) -> intToRational i
| SynRationalConst.Negate c2 -> NegRational (TcSynRationalConst c2)
| SynRationalConst.Rational(p, q, _) -> DivRational (intToRational p) (intToRational q)

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Service/ServiceInterfaceStubGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type InterfaceData =
| InterfaceData.ObjExpr (StripParenTypes ty, _) ->
let rec (|RationalConst|) =
function
| SynRationalConst.Integer i -> string i
| SynRationalConst.Integer(value = i) -> string i
| SynRationalConst.Rational (numerator, denominator, _) -> sprintf "(%i/%i)" numerator denominator
| SynRationalConst.Negate (RationalConst s) -> sprintf "- %s" s

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ type SynMeasure =
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynRationalConst =

| Integer of value: int32
| Integer of value: int32 * range: range

| Rational of numerator: int32 * denominator: int32 * range: range

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/SyntaxTree/SyntaxTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ type SynMeasure =
[<NoEquality; NoComparison; RequireQualifiedAccess>]
type SynRationalConst =

| Integer of value: int32
| Integer of value: int32 * range: range

| Rational of numerator: int32 * denominator: int32 * range: range

Expand Down
6 changes: 3 additions & 3 deletions src/Compiler/pars.fsy
Original file line number Diff line number Diff line change
Expand Up @@ -3292,15 +3292,15 @@ rationalConstant:

| INT32
{ if snd $1 then errorR(Error(FSComp.SR.lexOutsideThirtyTwoBitSigned(), lhs parseState))
SynRationalConst.Integer(fst $1) }
SynRationalConst.Integer(fst $1, lhs parseState) }

| MINUS INT32
{ if snd $2 then errorR(Error(FSComp.SR.lexOutsideThirtyTwoBitSigned(), lhs parseState))
SynRationalConst.Negate(SynRationalConst.Integer(fst $2)) }
SynRationalConst.Negate(SynRationalConst.Integer(fst $2, lhs parseState)) }

atomicUnsignedRationalConstant:
| INT32 { if snd $1 then errorR(Error(FSComp.SR.lexOutsideThirtyTwoBitSigned(), lhs parseState))
SynRationalConst.Integer(fst $1) }
SynRationalConst.Integer(fst $1, lhs parseState) }

| LPAREN rationalConstant rparen
{ $2 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8149,6 +8149,8 @@ FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Text.Range get_Range()
FSharp.Compiler.Syntax.SynPat: Int32 Tag
FSharp.Compiler.Syntax.SynPat: Int32 get_Tag()
FSharp.Compiler.Syntax.SynPat: System.String ToString()
FSharp.Compiler.Syntax.SynRationalConst+Integer: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynRationalConst+Integer: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynRationalConst+Integer: Int32 get_value()
FSharp.Compiler.Syntax.SynRationalConst+Integer: Int32 value
FSharp.Compiler.Syntax.SynRationalConst+Negate: FSharp.Compiler.Syntax.SynRationalConst Item
Expand All @@ -8168,7 +8170,7 @@ FSharp.Compiler.Syntax.SynRationalConst: Boolean IsRational
FSharp.Compiler.Syntax.SynRationalConst: Boolean get_IsInteger()
FSharp.Compiler.Syntax.SynRationalConst: Boolean get_IsNegate()
FSharp.Compiler.Syntax.SynRationalConst: Boolean get_IsRational()
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewInteger(Int32)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewInteger(Int32, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewNegate(FSharp.Compiler.Syntax.SynRationalConst)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewRational(Int32, Int32, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst+Integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8149,6 +8149,8 @@ FSharp.Compiler.Syntax.SynPat: FSharp.Compiler.Text.Range get_Range()
FSharp.Compiler.Syntax.SynPat: Int32 Tag
FSharp.Compiler.Syntax.SynPat: Int32 get_Tag()
FSharp.Compiler.Syntax.SynPat: System.String ToString()
FSharp.Compiler.Syntax.SynRationalConst+Integer: FSharp.Compiler.Text.Range get_range()
FSharp.Compiler.Syntax.SynRationalConst+Integer: FSharp.Compiler.Text.Range range
FSharp.Compiler.Syntax.SynRationalConst+Integer: Int32 get_value()
FSharp.Compiler.Syntax.SynRationalConst+Integer: Int32 value
FSharp.Compiler.Syntax.SynRationalConst+Negate: FSharp.Compiler.Syntax.SynRationalConst Item
Expand All @@ -8168,7 +8170,7 @@ FSharp.Compiler.Syntax.SynRationalConst: Boolean IsRational
FSharp.Compiler.Syntax.SynRationalConst: Boolean get_IsInteger()
FSharp.Compiler.Syntax.SynRationalConst: Boolean get_IsNegate()
FSharp.Compiler.Syntax.SynRationalConst: Boolean get_IsRational()
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewInteger(Int32)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewInteger(Int32, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewNegate(FSharp.Compiler.Syntax.SynRationalConst)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst NewRational(Int32, Int32, FSharp.Compiler.Text.Range)
FSharp.Compiler.Syntax.SynRationalConst: FSharp.Compiler.Syntax.SynRationalConst+Integer
Expand Down
1 change: 1 addition & 0 deletions tests/service/data/SyntaxTree/Measure/Constant - 06.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42<m^12345>
21 changes: 21 additions & 0 deletions tests/service/data/SyntaxTree/Measure/Constant - 06.fs.bsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ImplFile
(ParsedImplFileInput
("/root/Measure/Constant - 06.fs", false, QualifiedNameOfFile Constant - 06,
[], [],
[SynModuleOrNamespace
([Constant - 06], false, AnonModule,
[Expr
(Const
(Measure
(Int32 42, (1,0--1,2),
Seq
([Power
(Named ([m], (1,3--1,4)), Integer (12345, (1,5--1,10)),
(1,3--1,10))], (1,3--1,10)),
{ LessRange = (1,2--1,3)
GreaterRange = (1,10--1,11) }), (1,0--1,11)), (1,0--1,11))],
PreXmlDocEmpty, [], None, (1,0--1,11), { LeadingKeyword = None })],
(true, true), { ConditionalDirectives = []
CodeComments = [] }, set []))

(1,0)-(1,11) parse warning The declarations in this file will be placed in an implicit module 'Constant - 06' based on the file name 'Constant - 06.fs'. However this is not a valid F# identifier, so the contents will not be accessible from other files. Consider renaming the file or adding a 'module' or 'namespace' declaration at the top of the file.
dawedawe marked this conversation as resolved.
Show resolved Hide resolved
Loading