Ticket #280 (new defect)

Opened 1 year ago

Last modified 1 month ago

Clarification: "let" declarations are syntactically restricted and cannot appear except at the top level of a block/program

Reported by: lth Assigned to: lth
Type: defect Priority: minor
Milestone: Component: Spec
Version: Harmony Keywords: variables
Cc: brendan, jeffdyer, waldemar, david-sarah@jacaranda.org

Description

This should not be controversial: Unlike "var", "let" cannot appear eg as the direct dependent of a control flow statement, it can only appear at the top level of an explicitly brace-delimited block or at the program's top level:

let a = 1          // legal
package {
  let b = 2        // legal
  class C {
    let c = 3      // legal
    function f() {
      let d = 4    // legal
      if (x) {
        let e = 5  // legal
      }
      if (h)
        let f = 6  // ILLEGAL!
    }
  }
}

See also #253.

(This has no impact on let-block statements and let expressions.)

Attachments

Change History

Changed 1 year ago by jeffdyer

Agreed. This is uncontroversial. They are already disallowed by the ES4 grammar.

Jd

Changed 1 year ago by brendan

This is a no-brainer -- too bad JS1.7 in Firefox 2 had no brain and allowed let where ever var was allowed.

/be

Changed 1 year ago by waldemar

Agreed. This avoids hassles.

Changed 1 year ago by brendan

  • summary changed from Clarification: "let" definitions are syntactically restricted and cannot appear except at the top level of a block/program to Clarification: "let" declarations are syntactically restricted and cannot appear except at the top level of a block/program

Changed 1 year ago by lth

  • priority changed from major to trivial
  • summary changed from Clarification: "let" declarations are syntactically restricted and cannot appear except at the top level of a block/program to (Resolved) Clarification: "let" declarations are syntactically restricted and cannot appear except at the top level of a block/program

Changed 1 month ago by David-Sarah Hopwood

  • cc changed from brendan,jeffdyer,waldemar to brendan, jeffdyer, waldemar, david-sarah@jacaranda.org
  • keywords set to variables
  • summary changed from (Resolved) Clarification: "let" declarations are syntactically restricted and cannot appear except at the top level of a block/program to Clarification: "let" declarations are syntactically restricted and cannot appear except at the top level of a block/program
  • version changed from 4 to Harmony
  • priority changed from trivial to minor

Proposal still relevant to ES-Harmony.

Note: See TracTickets for help on using tickets.