Skip to content

Commit

Permalink
Rebase to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin committed May 26, 2022
1 parent 8b59d45 commit e9d3937
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Targets/ReScript/ReScriptHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module Attr =

module Naming =
let removeInvalidChars (s: string) =
s.ToCharArray()
s.Trim('"').ToCharArray()
|> Array.map (fun c -> if Char.isAlphabetOrDigit c || c = '_' || c = '\'' then c else '_')
|> System.String

Expand Down
20 changes: 10 additions & 10 deletions src/Targets/ReScript/Writer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,23 +1556,23 @@ let createStructuredText (rootCtx: Context) (stmts: Statement list) : Structured
let addAnonymousInterfaceExcluding ais current = addAnonymousInterfaceExcludingWithKnownTypes (knownTypes ()) ais current

match s with
| Module m ->
| Namespace m ->
let module' =
let scope =
if m.isNamespace then Scope.Default
else Scope.Module m.name
let node = {| StructuredTextNode.empty with comments = comments; scope = scope |}
let node = {| StructuredTextNode.empty with comments = comments; scope = Scope.Default |}
let module' = current |> getTrie [m.name] |> set node
let ctx = ctx |> Context.ofChildNamespace m.name
m.statements |> List.fold (folder ctx) module'
let current = current |> setTrie [m.name] module'
match module'.value with
| None -> current
| Some _ ->
let kind =
if m.isNamespace then Kind.OfNamespace
else Kind.OfModule
current |> addExport m.name kind (if m.isNamespace then "namespace" else "module")
| Some _ -> current |> addExport m.name Kind.OfNamespace "namespace"
| AmbientModule m ->
let module' =
let node = {| StructuredTextNode.empty with comments = comments; scope = Scope.Module m.name.unquoted |}
let module' = current |> getTrie [m.name.orig] |> set node
let ctx = ctx |> Context.ofChildNamespace m.name.orig
m.statements |> List.fold (folder ctx) module'
current |> setTrie [m.name.orig] module'
| Global m ->
current |> inTrie ["global"] (fun g ->
let node = {| StructuredTextNode.empty with scope = Scope.Global |}
Expand Down

0 comments on commit e9d3937

Please sign in to comment.