core.typed

Confusing error message when using clojure.core/defprotocol instead of clojure.core.typed/defprotocol>

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojure 1.5, core.typed 0.2.2

Description

Type checking a namespace using clojure.core/defprotocol instead of clojure.core.typed/defprotocol> results in the following error:

Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem

Although the user guide mentions defprotocol>, it's very easy to run into this error by accident, and the error message does not give the user any hints as to what might be wrong. In the long term it would be best if core.typed could deal with clojure.core/defprotocol. As a stopgap measure, maybe core.typed could detect this error and instruct the user to use clojure.core.typed/defprotocol> instead?

Activity

Timo Mihaljov made changes -
Field Original Value New Value
Description Type checking a namespace containing a Record that extends a Protocol results in the following error:

{noformat}
Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))
{noformat}

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem
Type checking a namespace containing a Record that extends a Protocol results in the following error:

{noformat}
Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))
{noformat}

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem

Although the user guide [mentions {{defprotocol>}}|https://github.com/clojure/core.typed/wiki/User-Guide#annotating-protocols], it's very easy to run into this error by accident, and the error message does not give the user any hints as to what might be wrong. In the long term it would be best if core.typed could deal with `clojure.core/defprotocol`. As a stopgap measure, maybe core.typed could detect this error and instruct the user to use {{clojure.core.typed/defprotocol>}} instead?
Priority Major [ 3 ] Minor [ 4 ]
Summary AssertionError when checking a namespace containing a Record that extends a Protocol Confusing error message when clojure.core.defprotocol used instead of clojure.core.typed/defprotocol>
Timo Mihaljov made changes -
Summary Confusing error message when clojure.core.defprotocol used instead of clojure.core.typed/defprotocol> Confusing error message when using clojure.core/defprotocol instead of clojure.core.typed/defprotocol>
Timo Mihaljov made changes -
Description Type checking a namespace containing a Record that extends a Protocol results in the following error:

{noformat}
Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))
{noformat}

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem

Although the user guide [mentions {{defprotocol>}}|https://github.com/clojure/core.typed/wiki/User-Guide#annotating-protocols], it's very easy to run into this error by accident, and the error message does not give the user any hints as to what might be wrong. In the long term it would be best if core.typed could deal with `clojure.core/defprotocol`. As a stopgap measure, maybe core.typed could detect this error and instruct the user to use {{clojure.core.typed/defprotocol>}} instead?
Type checking a namespace using {{clojure.core/defprotocol}} instead of {{clojure.core.typed/defprotocol>}} results in the following error:

{noformat}
Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))
{noformat}

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem

Although the user guide [mentions {{defprotocol>}}|https://github.com/clojure/core.typed/wiki/User-Guide#annotating-protocols], it's very easy to run into this error by accident, and the error message does not give the user any hints as to what might be wrong. In the long term it would be best if core.typed could deal with `clojure.core/defprotocol`. As a stopgap measure, maybe core.typed could detect this error and instruct the user to use {{clojure.core.typed/defprotocol>}} instead?
Timo Mihaljov made changes -
Description Type checking a namespace using {{clojure.core/defprotocol}} instead of {{clojure.core.typed/defprotocol>}} results in the following error:

{noformat}
Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))
{noformat}

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem

Although the user guide [mentions {{defprotocol>}}|https://github.com/clojure/core.typed/wiki/User-Guide#annotating-protocols], it's very easy to run into this error by accident, and the error message does not give the user any hints as to what might be wrong. In the long term it would be best if core.typed could deal with `clojure.core/defprotocol`. As a stopgap measure, maybe core.typed could detect this error and instruct the user to use {{clojure.core.typed/defprotocol>}} instead?
Type checking a namespace using {{clojure.core/defprotocol}} instead of {{clojure.core.typed/defprotocol>}} results in the following error:

{noformat}
Exception in thread "main" java.lang.AssertionError: Assert failed: 4: Cannot set! (U nil clojure.lang.MethodImplCache) to Any

Form:
        (set! (. f__5866__auto__ __methodImplCache) cache__5865__auto__)
(sub/subtype? (-> cval expr-type ret-t) (-> ctarget expr-type ret-t))
{noformat}

Here's a minimal project demonstrating the problem: https://github.com/noidi/core.typed-record-problem

Although the user guide [mentions {{defprotocol>}}|https://github.com/clojure/core.typed/wiki/User-Guide#annotating-protocols], it's very easy to run into this error by accident, and the error message does not give the user any hints as to what might be wrong. In the long term it would be best if core.typed could deal with {{clojure.core/defprotocol}}. As a stopgap measure, maybe core.typed could detect this error and instruct the user to use {{clojure.core.typed/defprotocol>}} instead?
Hide
Ambrose Bonnaire-Sergeant added a comment -

The first error is now about the protocol var being unannotated, which I'm happy enough should give people hints as to how to fix the error.

https://gist.github.com/frenchy64/6483863

Fixed with: https://github.com/clojure/core.typed/commit/f65a3d20ac35c955c1014c79c72167c480f9509d

Show
Ambrose Bonnaire-Sergeant added a comment - The first error is now about the protocol var being unannotated, which I'm happy enough should give people hints as to how to fix the error. https://gist.github.com/frenchy64/6483863 Fixed with: https://github.com/clojure/core.typed/commit/f65a3d20ac35c955c1014c79c72167c480f9509d
Ambrose Bonnaire-Sergeant made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Ambrose Bonnaire-Sergeant made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: