Skip to content

Commit c09d8d5

Browse files
committed
Add regression tests for previously fixed internal errors
Tests for issues that were fixed before this branch: - racket#82: plambda with dotted type variables - racket#229: Typed units with signatures from submodules - racket#318: Overriding method in typed class - racket#368: cast with wrong type gives contract failure - racket#378: cast in dead code - racket#425: Recursive type with intersection - racket#658: Invalid *-> type - racket#1028: with-handlers with multiple values - racket#1144: exn:srclocs? and similar identifiers - racket#1268: hash-union with #:combine Closes racket#318 Closes racket#425
1 parent 3f68e1b commit c09d8d5

File tree

10 files changed

+121
-0
lines changed

10 files changed

+121
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#;
2+
(exn-pred #rx"expected single value, got multiple")
3+
#lang typed/racket
4+
5+
;; Issue #1028: Incorrect with-handlers usage previously caused an internal
6+
;; typechecker error "get-range-result: should not happen". Fixed to give
7+
;; a proper type error about expecting single value.
8+
9+
(with-handlers ([exn:fail? (values #f #f)]) (values #t #t))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#;
2+
(exn-pred #rx"Inference for polymorphic keyword functions not supported")
3+
#lang typed/racket
4+
5+
;; Issue #1268: hash-union with #:combine previously caused an internal
6+
;; match-define error. Fixed to give a proper type error about polymorphic
7+
;; keyword function inference.
8+
9+
(require racket/hash)
10+
11+
(hash-union (make-hash) (make-hash) #:combine (lambda (a b) a))
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#;
2+
(exn-pred #rx"broke its own contract")
3+
#lang typed/racket
4+
5+
;; Issue #368: cast with wrong type previously threw an internal error
6+
;; "procedure-arity: contract violation" instead of a proper contract failure.
7+
8+
(cast 3 (-> Integer Integer))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#;
2+
(exn-pred #rx"cannot apply a non-polymorphic type")
3+
#lang typed/racket
4+
5+
;; Issue #425: Regression test - previously caused internal error
6+
;; "Base type L+ not in predefined-type-table" when using recursive
7+
;; type definitions with intersection types incorrectly.
8+
9+
(define-type (L+ T REST) (Pairof T (∩ (L+ T Any) REST)))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#;
2+
(exn-pred #rx"cannot apply a non-polymorphic type")
3+
#lang typed/racket
4+
5+
;; Issue #658: Invalid *-> type previously caused an internal error
6+
;; "erroneous syntax was not a syntax object". Fixed to give a proper
7+
;; type error about applying a non-polymorphic type.
8+
9+
(struct Node [{reachable : Edge}])
10+
(struct Edge [{to : Symbol} {cost : Positive-Integer}])
11+
12+
(define-type Graph [Immutable-HashTable Symbol Node])
13+
14+
(: make-graph (Node *-> Graph))
15+
(define (make-graph . lo-node)
16+
(make-immutable-hash))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#lang typed/racket
2+
3+
;; Issue #1144: Referencing certain identifiers like exn:srclocs? previously
4+
;; caused an internal "syntax-property: contract violation" error.
5+
;; Now properly returns the procedure.
6+
7+
(ann exn:srclocs? (-> Any Boolean))
8+
(ann rename-transformer? (-> Any Boolean))
9+
(ann set!-transformer? (-> Any Boolean))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#lang typed/racket
2+
3+
;; Issue #229: Typed units with signatures from submodules previously
4+
;; caused a "free-id-table-ref: contract violation" internal error.
5+
;; Now type checks correctly.
6+
7+
(module a typed/racket
8+
(provide foo^)
9+
10+
(define-signature foo^
11+
([some-class% : ClassTop])))
12+
13+
(require 'a)
14+
15+
(define-unit foo@
16+
(import)
17+
(export foo^)
18+
19+
(define some-class%
20+
(class object%
21+
(super-new))))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#lang typed/racket
2+
3+
;; Issue #318: Regression test - previously caused internal error when overriding
4+
;; a method that returns multiple values including 'this'.
5+
;; This was fixed in an earlier version of Typed Racket.
6+
7+
(define atree%
8+
(class object%
9+
(super-new)
10+
(define/public (m)
11+
(values #f this))))
12+
13+
(define state%
14+
(class atree%
15+
(super-new)
16+
(define/override (m)
17+
(values #f this))))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#lang typed/racket
2+
3+
;; Issue #378: cast in dead code previously caused an internal error
4+
;; "contract-def-property: thunk called too early". Now works correctly.
5+
6+
(define result
7+
(cond [#false (cast 1 Integer)]
8+
[else 2]))
9+
10+
(unless (= result 2)
11+
(error "expected 2"))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#lang typed/racket
2+
3+
;; Issue #82: Previously caused internal error "Tried to move vars to
4+
;; dbound that already exists" when using plambda with dotted type
5+
;; variables. Now type checks correctly.
6+
7+
(: f (-> One (List One String Char) : #:object (0 0)))
8+
(define (f [x : One])
9+
(let ([f (plambda: (a ...) [w : a ... a] w)])
10+
(f x "hello" #\c)))

0 commit comments

Comments
 (0)