Better error msg for structs with the same name
Thanks to Max for the suggestion
This commit is contained in:
parent
83dc3884aa
commit
52cc284d87
|
@ -51,6 +51,11 @@
|
|||
;; prints the binding locations of each type variable.
|
||||
(type-mismatch (format "`~a'" t1) (format "a different `~a'" t2)
|
||||
"type variables bound in different scopes")]
|
||||
[((Struct: n1 _ _ _ _ _) (Struct: n2 _ _ _ _ _))
|
||||
#:when (and (not (free-identifier=? n1 n2))
|
||||
(eq? (syntax-e n1) (syntax-e n2)))
|
||||
(type-mismatch (syntax-e n1) (format "a different ~a" (syntax-e n2))
|
||||
"incompatible struct types with the same name")]
|
||||
[((? Class?) (? Class?))
|
||||
(class-mismatch r1 r2)]
|
||||
[((Instance: (app resolve (? Class? c1))) (Instance: (app resolve (? Class? c2))))
|
||||
|
|
20
typed-racket-test/fail/same-name-struct-type.rkt
Normal file
20
typed-racket-test/fail/same-name-struct-type.rkt
Normal file
|
@ -0,0 +1,20 @@
|
|||
#;
|
||||
(exn-pred #rx"incompatible struct types with the same name")
|
||||
#lang racket/load
|
||||
|
||||
;; Test the error message for subtyping errors on struct types
|
||||
;; with the same name
|
||||
|
||||
(module a typed/racket
|
||||
(struct foo ([x : Integer]))
|
||||
(define a-foo (foo 3))
|
||||
(provide a-foo))
|
||||
|
||||
(module b typed/racket
|
||||
(struct foo ([x : String]))
|
||||
(define (f [a-foo : foo]) (foo-x a-foo))
|
||||
(provide f))
|
||||
|
||||
(module c typed/racket
|
||||
(require 'a 'b)
|
||||
(f a-foo))
|
Loading…
Reference in New Issue
Block a user