Skip to content

match macro: list-no-order loses type information on bound variables #689

Open
@MichaelBurge

Description

@MichaelBurge

What version of Racket are you using?

v6.12

What program did you run?

#lang typed/racket

(: id (-> Integer Integer))
(define (id x) x)

(match '(5)
  ((list-no-order (? integer? x)) (id x)))

What should have happened?

The program should output 5.

If list-no-order is changed to list, the program typechecks successfully.

If you got an error message, please include it here.

a.rkt:7:38: Type Checker: type mismatch
  expected: Integer
  given: Any
  in: x

Normally, changing x to #{x : Integer} works around issues with the match macro, but this is not available here:

a.rkt:6:0: Type Checker: Polymorphic function `car' could not be applied to arguments:
Types: (Pairof a b) -> (a : ((! (car (0 0)) False) | (: (car (0 0)) False)) : (car (0 0)))
       (Listof a) -> a
Arguments: (Listof Any)
Expected result: Integer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions