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

wrap-expr/c: blame-source points to use site rather than definition #2556

Open
lexi-lambda opened this issue Mar 25, 2019 · 0 comments
Open

Comments

@lexi-lambda
Copy link
Member

The blame-source field is supposed to describe where the contract is from, not where it’s used, even if the attachment of the contract is deferred. To illustrate, see the following behavior with contract-out:

#lang racket

(module a racket
  (provide (contract-out
            [f (-> integer? integer?)]))
  (define (f x)
    (add1 x)))

(module b racket
  (require (submod ".." a))
  (f 'not-an-integer))

(require 'b)
f: contract violation
  expected: integer?
  given: 'not-an-integer
  in: the 1st argument of
      (-> integer? integer?)
  contract from: (anonymous-module a)
  blaming: (anonymous-module b)
   (assuming the contract is correct)
  at: unsaved-editor:5.13

The equivalent example using expr/c puts the source at the use site, instead:

#lang racket

(module a racket
  (require syntax/parse/define)
  (provide f)
  (define-simple-macro (f e)
    #:declare e (expr/c #'integer?)
    (add1 e.c)))

(module b racket
  (require (submod ".." a))
  (f 'not-an-integer))

(require 'b)
f: contract violation
  expected: integer?
  given: 'not-an-integer
  in: macro argument contract
  contract from: (submod anonymous-module a)
  blaming: (submod (quote anonymous-module) b)
   (assuming the contract is correct)
  at: unsaved editor:12.5

The source location reported by wrap-expr/c is actually very useful, since normally that information isn’t reported anywhere, but it isn’t what blame-source is supposed to report.

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

No branches or pull requests

1 participant