Code Monkey home page Code Monkey logo

Comments (4)

lexi-lambda avatar lexi-lambda commented on June 18, 2024

After some more investigation, this typechecks as well.

(: f (Number [#:y Boolean] [#:z Nothing] -> Number))
(define (f x #:y [y #f] #:z [z 'this-can-be-anything])
  (if y "y is truthy" x))

I'm not sure why giving a parameter the Nothing type makes the typechecker do this. I'll keep looking into it, but I'm not completely sure where I should be looking.

from typed-racket.

lexi-lambda avatar lexi-lambda commented on June 18, 2024

Also, this produces an internal error with no useful information.

(: g (Nothing -> Any))
(define (g [x 'x] [y 'y]) 'g)
Internal Typechecker Error: no type for (if y11 y9 (quote y)) at: #f line #f col #f
while typechecking:
here
originally:
here

EDIT: Looks like this is actually a bug in the optimizer, since turning off optimizations stops it from erroring, though it feels indicative of a larger problem.

from typed-racket.

mbutterick avatar mbutterick commented on June 18, 2024

I believe I’ve independently encountered this bug. The function f1 compiles, but loses its types (the types of 'bool' and 'syms' are reported as Any).

But if I add a dummy keyword argument, as in f2, then everything typechecks fine: 'bool' is reported as a Boolean and 'syms' is (Listof Symbol).

(: f1 (() (Boolean) #:rest Symbol . ->* . Any))
(define (f1 [bool #t] . syms)
 bool
 syms)

(: f2 (() (Boolean #:x Integer) #:rest Symbol . ->* . Any))
(define (f2 [bool #t] #:x [x 42] . syms)
 bool
 syms)

from typed-racket.

lexi-lambda avatar lexi-lambda commented on June 18, 2024

@mbutterick I've filed a separate bug report for that case, #58, based on your information. It may turn out to be related, but I'm not sure, and I think it's quite possible that they're different.

from typed-racket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.