racket / racket/typed-racket

#:opaque allows passing higher-order values out with a flat contract, is unsound

Open
#247 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This program errors in the typed module.

#lang racket

(module m1 racket
  (provide f g)
  (define (f x) #t)
  (define (g x) (x 0)))

(module m2 typed/racket
  (require/typed (submod ".." m1)
                 [#:opaque F f]
                 [g (F -> Any)])
  (: fun : String -> String)
  (define (fun z) (string-append "hi" z))
  (if (f fun)
      (g fun)
      #t))

(require 'm2)

Possible solutions:

  • F could turn into (and/c any-wrap/c f)
  • we could generate some sort of cast at the site of the implicit upcast here (the call to g).
  • ....

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.

Research direction

Run the Racket program in the issue to reproduce the unsound higher-order value flow. Start by tracing require/typed handling of #:opaque and the implicit upcast at the call to g. Done means the typed module no longer permits higher-order values to escape through a flat contract unsafely, with a sound behavior chosen and validated.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.