racket / rhombus

Rhombus programming language
Other
350 stars 62 forks source link

A `let` before another `def` in the same block #480

Closed usaoc closed 7 months ago

usaoc commented 8 months ago

(Found during the writing of e7dc0d9; opening for public attention)

Currently, a let can “scope over” another def in the same block:

#lang rhombus

block:
  let x = "outer"
  def x = "inner"
  // refers to the `let` binding, i.e., "outer"
  x

This is because the let binding has an extra scope (in order to achieve “forward definition”) compared to the def binding. Is this a reasonable behavior? And in general, how should let and def interact within the same block?

samth commented 8 months ago

I think either an error or "inner" are acceptable behaviors here.

mflatt commented 7 months ago

Made an error in bfbb0975096f34a8bbe9e566ce912555427a114a