racket / racket/typed-racket

TR fails to type check optional lambdas with type annotations

Open
#997 0 comments 0 reactions 1 assignee View on GitHub

@capfredf is already working on this.

Since Nov 20, 2020.

bug
Dominant language
Racket
Stars
575
Forks
106
Avg merge
2h 1m
Merged PRs (30d)
2

Description

What version of Racket are you using?

Racket[cs] 7.9.0.5 on 56560736379fba7b4d72d97f29f46fa0cbf15b85

What program did you run?
(: append-bar (->* () (Natural) #:rest Any String))
(define (append-bar [how-many 1] . rst)
    (apply string-append "hi" (make-list how-many "bar"))
What should have happened?

The program should typecheck

If you got an error message, please include it here.
Type Checker: Expected a function of type (-> Nothing String), but got a function with the wrong arity
;   in: (define (append-bar (how-many 1) . rst) (apply string-append "hi" (make-list how-many "bar")))

OTOH, the same function with in-line annotation makes the typechecker happy.

(define (append-bar2 [how-many : Natural 1] . [rst : Any *]) : String
    (apply string-append "hi" (make-list how-many "bar")))

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.