racket / racket/typed-racket

TR: local type inference fails in class bodies, and type error identifies the wrong expression

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

@samth is already working on this.

Since Apr 9, 2015.

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

Description

Originally submitted on: Tue Dec 30 18:04:01 -0500 2014

The error is

Type Checker: missing type for identifier;
consider adding a type annotation with `:'
identifier: self52876 in: dc

The highlighted expression is dc in (define alpha (send dc get-alpha)), which is very confusing.

Uncommenting (: alpha Nonnegative-Real) allows the program to typecheck. But this information is already known: replacing the type declaration with (: alpha String) results in the following error message:

Type Checker: type mismatch
expected: String
given: Nonnegative-Real in: alpha

Steps to Reproduce:
#lang typed/racket

(require typed/racket/draw
         typed/racket/class)

(define foo%
  (class object%
    (init-field [dc : (Instance DC<%>)])
    (super-new)
    ;(: alpha Nonnegative-Real)
    (define alpha (send dc get-alpha))))
Release:
6.1.1.6--2014-12-21(-/f)
Environment:
unix "Linux snoopy 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64
 x86_64 x86_64 GNU/Linux" (x86_64-linux/3m) (get-display-depth) = 32
Human Language: english
(current-memory-use) 633168392
raco pkg (show):
Installation-wide:
 Package                 Checksum           Source
 disassemble             cf0ee3a5...        catalog...ssemble
 drbayes                                    link...il/drbayes
 main-distribution       67868e03...        catalog...ibution
 main-distribution-test  ca4a870e...        catalog...on-test
 nonplussed              f6c06999...        url.../nonplussed
 optimization-coach      be5f7908...        catalog...n-coach
 pict3d                                     link...eil/pict3d
 plot                    e536986e...        clone...path=plot
 racket-lib                                 static-link...lib
 rsound                  4f5d4d15...        catalog rsound
 slideshow-latex         9275fecb...        catalog...w-latex
 [214 auto-installed packages not shown]
User-specific for installation "development":
 [none]



Collections:
("/home/neil/.racket/development/collects"
 (non-existent-path))
("/home/neil/plt-fresh/racket/collects"
 (".gitignore" "acks" "compiler" "data" "db" "dynext" "ffi" "file" "info" "info-domain"
 "json" "launcher" "net" "openssl" "pkg" "planet" "racket" "raco" "reader" "realm" "s-exp"
 "setup" "syntax" "unstable" "version" "xml"))

Recent Internal Errors: 
Computer Language: (("Determine language from source") (#(#t print mixed-fraction-e #f #t
 none) (default) #() "#lang racket\n" #t #f ((test) (main)) #t))
This bug was converted from Gnats bug 14909.

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.