Skip to content

Commit

Permalink
[Python] Fixed null reference exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ncave committed Feb 10, 2024
1 parent 3fe67d6 commit ddb9beb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/Fable.Transforms/Python/Fable2Python.fs
Original file line number Diff line number Diff line change
Expand Up @@ -579,17 +579,14 @@ module Helpers =
| Fable.Any -> true
| _ -> false

let index = (Seq.initInfinite id).GetEnumerator()

let removeNamespace (fullName: string) =
fullName.Split('.')
|> Array.last
|> (fun name -> name.Replace("`", "_"))
|> Helpers.clean

let getUniqueIdentifier (name: string) : Identifier =
do index.MoveNext() |> ignore
let idx = index.Current.ToString()
let idx = Naming.getUniqueIndex ()

let deliminator =
if Char.IsLower name[0] then
Expand Down
6 changes: 6 additions & 0 deletions src/Fable.Transforms/Python/Prelude.fs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ module Naming =

let reflectionSuffix = "_reflection"

let mutable uniqueIndex = 0

let getUniqueIndex () =
let idx = uniqueIndex
uniqueIndex <- uniqueIndex + 1
idx

let preventConflicts conflicts originalName =
let rec check originalName n =
Expand Down

0 comments on commit ddb9beb

Please sign in to comment.