soft-contract icon indicating copy to clipboard operation
soft-contract copied to clipboard

(Typed Racket) -𝒾: contract violation blaming <pkgs>/soft-contract/parse/private.rkt

Open bennn opened this issue 7 years ago • 3 comments

soft-contract blames itself when it tries to verify a program that depends on a typed racket program.

Example program

"b.rkt"

#lang typed/racket/base

(: f (-> Integer Integer))
(define (f x)
  (+ x 2))

(provide f)

"a.rkt"

#lang racket

(require "b.rkt")

(define (g x)
  (f (f x)))

(provide (contract-out (g (-> integer? integer?))))

Error Message

-𝒾: contract violation
  expected: (or/c String Symbol)
  given: '(#<path:/Users/ben/code/racket/my-pkgs/require-typed-scv/test/gtp/lnm/bug/b.rkt> #%contract-defs)
  in: the 2nd argument of
      (-> Symbol (or/c String Symbol) any)
  contract from: 
      <pkgs>/soft-contract/ast/definition.rkt
  blaming: <pkgs>/soft-contract/parse/private.rkt
   (assuming the contract is correct)
  at: <pkgs>/soft-contract/ast/definition.rkt:58.8
  context...:

bennn avatar Jun 05 '17 23:06 bennn

I fixed the error, which came from the parser. But there are still problems from requiring a typed/racket module.

philnguyen avatar Jun 06 '17 04:06 philnguyen

@bennn did you have a rudimentary way to convert types to contracts? Worst case I can try using that to convert everything to contracted untyped modules first...

philnguyen avatar Jun 16 '17 16:06 philnguyen

Yes, very rudimentary. https://github.com/bennn/require-typed-scv/blob/master/private/parse-type.rkt#L17

Just parses surface syntax. It would be better to parse expanded TR syntax ... and I think that is the best we could do without changing TR's type->contract function to have a text backend.

bennn avatar Jun 17 '17 04:06 bennn