Skip to content

Function declaration throws in REPL #10950

Description

@mik-jozef
  • Version: v7.4.0
  • Platform: Windows 10 64bit

The following code is executed normally from a file, but throws from REPL.

function f(){} f()
// REPL output:
var f = function f(){} f()
                       ^
SyntaxError: Unexpected identifier

I guess the function declaration is converted to function expression which unlike the declaration requires semicolon. However, everything works fine with 5; function f(){} f().

Also, this code works in REPL: function f(){}, a=9, but it shouldn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues asking questions about Node.js.replIssues and PRs related to the REPL subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions