Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shadow-cljs warnings that complain about marker protocol #2

Merged
merged 1 commit into from
Aug 19, 2020

Conversation

athos
Copy link
Owner

@athos athos commented Aug 18, 2020

Although Pogonos now does not officially support shadow-cljs, while I was trying it privately, it told me there were some infer warnings, which clj -Rcljs -m cljs.main never ever complained:

------ WARNING #1 - :infer-warning ---------------------------------------------
 File: /path/to/pogonos/src/pogonos/nodes.cljc:19:1
--------------------------------------------------------------------------------
  16 |
  17 | (defrecord Partial [name indent])
  18 |
  19 | (defrecord Comment [body]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. Comment -prototype) -pogonos$nodes$Invisible$)
--------------------------------------------------------------------------------
  20 |   Invisible)
  21 |
  22 | (defrecord SetDelimiter [open close]
  23 |   Invisible)
--------------------------------------------------------------------------------

------ WARNING #2 - :infer-warning ---------------------------------------------
 File: /path/to/pogonos/src/pogonos/nodes.cljc:22:1
--------------------------------------------------------------------------------
  19 | (defrecord Comment [body]
  20 |   Invisible)
  21 |
  22 | (defrecord SetDelimiter [open close]
-------^------------------------------------------------------------------------
 Cannot infer target type in expression (. (. SetDelimiter -prototype) -pogonos$nodes$Invisible$)
--------------------------------------------------------------------------------
  23 |   Invisible)
  24 |
--------------------------------------------------------------------------------

------ WARNING #3 - :infer-warning ---------------------------------------------
 File: /path/to/pogonos/src/pogonos/core.cljc:37:26
--------------------------------------------------------------------------------
  34 |   ([in opts]
  35 |    (let [buf (parse/make-node-buffer)
  36 |          out (fn [x]
  37 |                (when-not (satisfies? nodes/Invisible x)
--------------------------------^-----------------------------------------------
 Cannot infer target type in expression (. x -pogonos$nodes$Invisible$)
--------------------------------------------------------------------------------
  38 |                  (buf x)))
  39 |          opts (fixup-options opts #?(:clj partials/resource-partials))]
  40 |      (parse/parse in out opts)
  41 |      (with-meta
--------------------------------------------------------------------------------

Roughly, these warnings seem to complain about a marker protocol (i.e. Invisible). After some exploration, it turned out that removing the protocol from the two record implementations resolved the warnings.

This PR replaces the Invisible protocol with a new one named IVisibility, which has a single method. The change not only resolves the above issue, but also makes the caller code more straightforward. It is indeed a breaking change, but has almost no impact on user code, I guess.

@codecov
Copy link

codecov bot commented Aug 18, 2020

Codecov Report

Merging #2 into master will decrease coverage by 0.08%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #2      +/-   ##
==========================================
- Coverage   90.25%   90.16%   -0.09%     
==========================================
  Files          10       10              
  Lines         718      722       +4     
  Branches       39       38       -1     
==========================================
+ Hits          648      651       +3     
- Misses         31       33       +2     
+ Partials       39       38       -1     
Impacted Files Coverage Δ
src/pogonos/nodes.cljc 86.66% <60.00%> (-13.34%) ⬇️
src/pogonos/core.cljc 86.90% <100.00%> (+1.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4615511...6605848. Read the comment docs.

@athos athos merged commit 5f0e12f into master Aug 19, 2020
@athos athos deleted the fix/shadow-cljs-warnings branch August 19, 2020 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant