racket / racket/redex

in-hole within #:refers-to causes contract violation

Open
#168 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
112
Forks
42
PR merge metrics
No merged PRs in 30d

Description

The intention of this program is for the scope of a define to be its entire surrounding context.

#lang racket

(require redex/reduction-semantics)

(define-language L
  [ x ::= variable-not-otherwise-mentioned]
  [ e ::= x natural ]
  [ s ::= (begin s ...) (define x e) e]
  [ S ::= hole (begin s ... S s ...)]
  #:binding-forms
  (in-hole S (define x e) #:refers-to x)
  )

(default-language L)

(test-equal (term (define foo 5))
            (term (define bar 5)))

(test-equal (term (begin (define foo 5)
                         (define bar 10)
                         bar
                         foo
                         ))
            (term (begin (define bar 5)
                         (define baz 10)
                         baz
                         bar)))

I'm not sure what I expected the semantics of this to be, but the error message should at least be different:

car: contract violation
  expected: pair?
  given: 5
  context...:
   /home/mburge/work/vendor/redex/redex-lib/redex/private/binding-forms.rkt:654:4: loop
   [repeats 4 more times]
   /home/mburge/work/vendor/redex/redex-lib/redex/private/binding-forms.rkt:651:0: rec-freshen-spec
   /home/mburge/work/vendor/redex/redex-lib/redex/private/binding-forms.rkt:184:0: canonicalize
   /home/mburge/work/vendor/redex/redex-lib/redex/private/binding-forms.rkt:152:0: α-equal?
   /home/mburge/work/vendor/redex/redex-lib/redex/private/reduction-semantics.rkt:3165:0: test-equal/proc
   "/home/mburge/work/tmp/a.rkt": [running body]
   for-loop
   run-module-instance!125
   perform-require!78

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

Reproduce the example with test-equal and inspect redex/private/binding-forms.rkt, especially rec-freshen-spec and loop, along with redex/private/reduction-semantics.rkt. Trace how the #:refers-to binding form handles the in-hole context, then verify that the example reports a meaningful error rather than a car contract violation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.