File tree Expand file tree Collapse file tree 4 files changed +19
-4
lines changed
Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010### Fixed
1111
12+ * [ Python] Fix record member method naming (by @dbrattli )
1213* [ Python] Fix regression, named arguments not being converted to snake_case (by @dbrattli )
1314* [ Python] Fix regression, erased interfaces should not generate code (#4277 ) (by @dbrattli )
1415
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010### Fixed
1111
12- * Fix regression, Python erased interfaces should not generate code (#4277 ) (by @dbrattli )
12+ * [ Python] Fix regression, record member method naming (by @dbrattli )
13+ * [ Python] Fix regression, named arguments not being converted to snake_case (by @dbrattli )
14+ * [ Python] Fix regression, erased interfaces should not generate code (#4277 ) (by @dbrattli )
1315
1416### Changed
1517
Original file line number Diff line number Diff line change @@ -188,6 +188,10 @@ module Util =
188188 | None -> InstancePropertyBacking // Conservative fallback for unknown entities
189189 | _ -> RegularField
190190
191+ /// Checks if a field name is an actual record field (not a property/method defined on the record)
192+ let isRecordField ( ent : Fable.Entity ) ( fieldName : string ) =
193+ ent.FSharpFields |> List.exists ( fun f -> f.Name = fieldName)
194+
191195 // Helper function to apply the appropriate naming convention based on field type and naming kind
192196 let applyFieldNaming
193197 ( com : IPythonCompiler )
@@ -202,9 +206,8 @@ module Util =
202206 match narrowedType with
203207 | Fable.AnonymousRecordType _ when handleAnonymousRecords -> fieldName // Use the field name as is for anonymous records
204208 | Fable.DeclaredType( entityRef, _) ->
205- // Only apply naming convention for user-defined F# Records (not built-in F# Core types)
206209 match com.TryGetEntity entityRef with
207- | Some ent when shouldUseRecordFieldNamingForRef entityRef ent ->
210+ | Some ent when shouldUseRecordFieldNamingForRef entityRef ent && isRecordField ent fieldName ->
208211 fieldName |> Naming.toRecordFieldSnakeCase |> Helpers.clean
209212 | _ -> fieldName |> Naming.toPythonNaming // Fallback to Python naming for other types
210213 | _ -> fieldName |> Naming.toPropertyNaming
Original file line number Diff line number Diff line change @@ -190,4 +190,13 @@ type CasingRecord =
190190let ``test Record with both camel - case and pascal - case fields don't conflict`` () =
191191 let x = { firstName = " John" ; FirstName = " Jane" }
192192 equal " John" x.firstName
193- equal " Jane" x.FirstName
193+ equal " Jane" x.FirstName
194+
195+ type RecordWithProperty =
196+ { items: string list }
197+ member this.fullName = String.concat " - " this.items
198+
199+ [<Fact>]
200+ let ``test Record property access uses correct naming`` () =
201+ let x = { items = [ " Hello" ; " World" ] }
202+ equal " Hello - World" x.fullName
You can’t perform that action at this time.
0 commit comments