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

Open
#689 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Domain
compilers

Research direction

Start by running the supplied #lang typed/racket reproducer and compare it with the working list pattern. Investigate the match macro's list-no-order handling of the bound variable x. Done means the original program typechecks and outputs 5 without an explicit type annotation.

Written by the indexing model from the issue text.

Description

match
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
Dominant language
Racket
Stars
575
Forks
106
Avg merge
2h 1m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from racket/typed-racket

All issues in racket/typed-racket

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.