diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 69e2c483ddf..1c0997851e4 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -178,7 +178,6 @@ module MutRecShapes = let iterTyconsWithEnv f1 env xs = iterWithEnv f1 (fun _env _x -> ()) (fun _env _x -> ()) (fun _env _x -> ()) env xs - /// Indicates a declaration is contained in the given module let ModuleOrNamespaceContainerInfo modref = ContainerInfo(Parent modref, Some(MemberOrValContainerInfo(modref, None, None, NoSafeInitInfo, []))) diff --git a/src/Compiler/SyntaxTree/LexFilter.fs b/src/Compiler/SyntaxTree/LexFilter.fs index 64bc43c6ebc..e592960c6ba 100644 --- a/src/Compiler/SyntaxTree/LexFilter.fs +++ b/src/Compiler/SyntaxTree/LexFilter.fs @@ -1172,6 +1172,11 @@ type LexFilterImpl ( delayToken (pool.UseShiftedLocation(tokenTup, INFIX_AT_HAT_OP "^", 1, 0)) delayToken (pool.UseShiftedLocation(tokenTup, LESS res, 0, -1)) pool.Return tokenTup + + | INFIX_COMPARE_OP ">:" -> + delayToken (pool.UseShiftedLocation(tokenTup, COLON, 1, 0)) + delayToken (pool.UseShiftedLocation(tokenTup, GREATER res, 0, -1)) + pool.Return tokenTup // NOTE: this is "<@" | LQUOTE ("<@ @>", false) -> delayToken (pool.UseShiftedLocation(tokenTup, INFIX_AT_HAT_OP "@", 1, 0)) diff --git a/src/Compiler/lex.fsl b/src/Compiler/lex.fsl index e8edd3086c1..b3ddfad4a13 100644 --- a/src/Compiler/lex.fsl +++ b/src/Compiler/lex.fsl @@ -112,6 +112,10 @@ let checkExprOp (lexbuf:UnicodeLexing.Lexbuf) = deprecatedWithError (FSComp.SR.lexCharNotAllowedInOperatorNames(":")) lexbuf.LexemeRange if lexbuf.LexemeContains '$' then deprecatedWithError (FSComp.SR.lexCharNotAllowedInOperatorNames("$")) lexbuf.LexemeRange + +let checkExprGreaterColonOp (lexbuf:UnicodeLexing.Lexbuf) = + if lexbuf.LexemeContains '$' then + deprecatedWithError (FSComp.SR.lexCharNotAllowedInOperatorNames("$")) lexbuf.LexemeRange let unexpectedChar lexbuf = LEX_FAILURE (FSComp.SR.lexUnexpectedChar(lexeme lexbuf)) @@ -945,7 +949,9 @@ rule token (args: LexArgs) (skip: bool) = parse | ignored_op_char* ('@'|'^') op_char* { checkExprOp lexbuf; INFIX_AT_HAT_OP(lexeme lexbuf) } - | ignored_op_char* ('=' | "!=" | '<' | '>' | '$') op_char* { checkExprOp lexbuf; INFIX_COMPARE_OP(lexeme lexbuf) } + | ignored_op_char* ('=' | "!=" | '<' | '$') op_char* { checkExprOp lexbuf; INFIX_COMPARE_OP(lexeme lexbuf) } + + | ignored_op_char* ('>') op_char* { checkExprGreaterColonOp lexbuf; INFIX_COMPARE_OP(lexeme lexbuf) } | ignored_op_char* ('&') op_char* { checkExprOp lexbuf; INFIX_AMP_OP(lexeme lexbuf) } diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/BasicOperatorNames.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/BasicOperatorNames.fs index 678198d625c..fa340382024 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/BasicOperatorNames.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/BasicOperatorNames.fs @@ -14,3 +14,5 @@ if !10 <> 3628800 then failwith "Failed: : 1" // Binary let (<<<) x y = x - x * y if 10 <<< 3 <> -20 then failwith "Failed: : 2" + +let (>:) x y = x + x * y diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/OperatorNames.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/OperatorNames.fs index e9cd52bafba..89b5d4c4ad0 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/OperatorNames.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/OperatorNames/OperatorNames.fs @@ -73,4 +73,4 @@ module OperatorNames = |> asExe |> withOptions ["--warnaserror+"; "--nowarn:3370"; "--nowarn:988"] |> compileExeAndRun - |> shouldSucceed + |> shouldSucceed \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs index a43e7eb2491..41a672132be 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/ClassesTests.fs @@ -686,4 +686,22 @@ type X = app |> withLangVersion80 |> compile + |> shouldSucceed + + [] + let ``No separator between member and type annotation`` () = + FSharp """ + type IFoo<'T> = + abstract member Bar<'T>: string -> unit + """ + |> typecheck + |> shouldSucceed + + [] + let ``Separator between member and type annotation`` () = + FSharp """ + type IFoo<'T> = + abstract member Bar<'T> : string -> unit + """ + |> typecheck |> shouldSucceed \ No newline at end of file