racket / racket/rhombus

Use-site binder hygiene bug for `let`

Open
#474 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
601
Forks
74
Avg merge
2d 10h
Merged PRs (30d)
5

Description

I've previously discussed this with @mflatt , but I figure I should make a ticket.

Consider this program:

#lang rhombus/and_meta

block:
  let x = "outer"
  defn.macro 'm $id':
    'let $id = "inner"
     x'
  m x

It returns "inner", but I think it should return "outer" like the similar Racket program does:

(define x "outer")
(define-syntax-rule (m id)
 (let ([id "inner"])
   x))
(m x)

I want to point this out now because I saw https://github.com/racket/racket/pull/4929, which proposes to add something new to the syntax-local- zoo to support the implementation of Rhombus let. I'm a little skeptical of the current implementation strategy for let given that it gets this use-site binder hygiene wrong, and it feels like it'd be unfortunate to expose more low level syntax-local- operations that could point users towards implementations of scoping structures that don't get hygiene right.

In contrast, an implementation of let using definition contexts and local-expand should be able to avoid this problem because one of the things definition contexts encapsulate is a set of local use-site scopes. I don't know enough about Rhombus to know what other implementation constraints there are, though.

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

Start by reproducing the Rhombus example in the issue and compare its result with the similar Racket program. Read the current Rhombus let implementation and the definition-context and local-expand approach discussed in the report; done means the macro expansion preserves the outer x and returns "outer" without introducing an unsuitable low-level operation.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.