From 106b93583572b0909b594fd7e501703053015ed6 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Tue, 13 Jan 2026 15:04:10 +0100 Subject: [PATCH 1/2] Type checker: mark generated event tree nodes as synthetic --- .../Checking/Expressions/CheckExpressions.fs | 2 ++ tests/FSharp.Compiler.Service.Tests/Symbols.fs | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 4826683425..ae8c9b386d 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -2651,6 +2651,7 @@ module EventDeclarationNormalization = let MakeOne (prefix, target) = let declPattern = RenameBindingPattern (fun s -> prefix + s) declPattern let argName = "handler" + let mBinding = mBinding.MakeSynthetic() // modify the rhs and argument data let bindingRhs, valSynData = @@ -2662,6 +2663,7 @@ module EventDeclarationNormalization = match rhsExpr with // Detect 'fun () -> e' which results from the compilation of a property getter | SynExpr.Lambda (args=SynSimplePats.SimplePats(pats = []); body=trueRhsExpr; range=m) -> + let m = m.MakeSynthetic() let rhsExpr = mkSynApp1 (SynExpr.DotGet (SynExpr.Paren (trueRhsExpr, range0, None, m), range0, SynLongIdent([ident(target, m)], [], [None]), m)) (SynExpr.Ident (ident(argName, m))) m // reconstitute rhsExpr diff --git a/tests/FSharp.Compiler.Service.Tests/Symbols.fs b/tests/FSharp.Compiler.Service.Tests/Symbols.fs index 0fbd8ec84a..28a352c250 100644 --- a/tests/FSharp.Compiler.Service.Tests/Symbols.fs +++ b/tests/FSharp.Compiler.Service.Tests/Symbols.fs @@ -1287,6 +1287,18 @@ type T() = Assert.False hasPropertySymbols + [] + let ``CLIEvent 01 - Synthetic range`` () = + let _, checkResults = getParseAndCheckResults """ +type T() = + [] + member this.Event = Event().Publish +""" + checkResults.GetAllUsesOfAllSymbolsInFile() + |> Seq.exists (fun symbolUse -> symbolUse.Symbol.DisplayNameCore = "handler") + |> shouldEqual false + + module Delegates = [] let ``IL metadata`` () = From 269d55478b7c3e82ff40ae6d9ff97417392e838b Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Tue, 13 Jan 2026 15:25:38 +0100 Subject: [PATCH 2/2] Release notes --- docs/release-notes/.FSharp.Compiler.Service/10.0.200.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.200.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.200.md index dcb9533f6a..54f1b13f05 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.200.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.200.md @@ -5,6 +5,7 @@ * Fix `--preferreduilang` switch leaking into `fsi.CommandLineArgs` when positioned after script file ([PR #19151](https://github.com/dotnet/fsharp/pull/19151)) * Fixed runtime crash when using interfaces with unimplemented static abstract members as constrained type arguments. ([Issue #19184](https://github.com/dotnet/fsharp/issues/19184)) * Fix delegates with `[]` and caller info attributes failing to compile. ([Issue #18868](https://github.com/dotnet/fsharp/issues/18868), [PR #19069](https://github.com/dotnet/fsharp/pull/19069)) +* Type checker: mark generated event tree nodes as synthetic ([PR #19213](https://github.com/dotnet/fsharp/pull/19213)) ### Added