bad error message in get-* functions #6

Closed
opened 6 years ago by odanoburu · 2 comments
odanoburu commented 6 years ago (Migrated from github.com)
> (get-tag "oi")
; car: contract violation
;   expected: pair?
;   given: "oi"

from my understanding, the define+provide+safe macro should be exporting get-tag with a contract that would raise an error blaming my call to get-tag not the hidden call to car. am I doing something wrong? or is this a bug in the sugar library? if so, the only way I know of fixing this is by using regular constructs like define/contract, hence the absence of an accompanying PR!

``` > (get-tag "oi") ; car: contract violation ; expected: pair? ; given: "oi" ``` from my understanding, the `define+provide+safe` macro should be exporting `get-tag` with a contract that would raise an error blaming my call to `get-tag` not the hidden call to `car`. am I doing something wrong? or is this a bug in the `sugar` library? if so, the only way I know of fixing this is by using regular constructs like `define/contract`, hence the absence of an accompanying PR!
mbutterick commented 6 years ago (Migrated from github.com)

To get the contract you have to import via the safe submodule:

#lang racket
(require (submod txexpr safe))
(get-tag "oi")

Result:

get-tag: contract violation
  expected: txexpr?
  given: "oi"
  in: the 1st argument of
      (-> txexpr? txexpr-tag?)
  contract from: 
      (txexpr/txexpr/base.rkt safe)
  blaming: anonymous-module
   (assuming the contract is correct)
To get the contract you have to import via the `safe` submodule: ```racket #lang racket (require (submod txexpr safe)) (get-tag "oi") ``` Result: ```racket get-tag: contract violation expected: txexpr? given: "oi" in: the 1st argument of (-> txexpr? txexpr-tag?) contract from: (txexpr/txexpr/base.rkt safe) blaming: anonymous-module (assuming the contract is correct) ```
odanoburu commented 6 years ago (Migrated from github.com)

ah, that's interesting! sorry for the noise.

ah, that's interesting! sorry for the noise.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/txexpr#6
Loading…
There is no content yet.