Skip to content

Commit b552dd1

Browse files
committed
Fix some edge cases.
1 parent b9505cd commit b552dd1

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/backend/escodegen/writer.wisp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,13 +1144,14 @@
11441144
(let [default-type? (= type 'default)
11451145
nil-type? (nil? type)
11461146

1147-
type-name (cond (= type 'default) '_
1148-
(nil? type) (symbol "nil")
1147+
type-name (cond (nil? type) (symbol "nil")
1148+
(= type 'default) '_
11491149
(= type 'number) 'Number
11501150
(= type 'string) 'String
11511151
(= type 'boolean) 'Boolean
11521152
(= type 'vector) 'Array
11531153
(= type 'function) 'Function
1154+
(= type 're-pattern) 'RegExp
11541155
(= (namespace type) "js") type
11551156
:else nil)
11561157

src/runtime.wisp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,20 @@
7474
(defn ^boolean satisfies?
7575
"Returns true if x satisfies the protocol"
7676
[protocol x]
77-
(cond (identical? x nil)
78-
(.-wisp_core$IProtocol$nil protocol)
79-
80-
(identical? x null)
81-
(.-wisp_core$IProtocol$nil protocol)
82-
83-
:else (or (aget x (aget protocol 'wisp_core$IProtocol$id))
84-
(.-wisp_core$IProtocol$_ protocol))))
77+
(or (.-wisp_core$IProtocol$_ protocol)
78+
(cond (identical? x nil)
79+
(or (.-wisp_core$IProtocol$nil protocol) false)
80+
81+
(identical? x null)
82+
(or (.-wisp_core$IProtocol$nil protocol) false)
83+
84+
:else (or (aget x (aget protocol 'wisp_core$IProtocol$id))
85+
(aget protocol
86+
(str "wisp_core$IProtocol$"
87+
(.replace (.replace (.call Object.prototype.toString x)
88+
"[object " "")
89+
#"\]$" "")))
90+
false))))
8591

8692
(defn ^boolean contains-vector?
8793
"Returns true if vector contains given element"

0 commit comments

Comments
 (0)