Skip to content

Return statements inside object constructors behave inconsistently #325

Description

@IsaacOscar

Consider the following four methods:

method foo1 {
  object { return "Hello" }
  "Goodbye" }

method foo2 {
  object { {return "Hello"}.apply }
  "Goodbye" }

method foo3 {
  object { return "Hello" }}

method foo4 {
  object { {return "Hello"}.apply }}

I would expect all 4 methods to return "Hello" when called, however this is not the case:

print(foo1) // prints "Goodbye"
print(foo2) // prints "hello"
print(foo3) // prints "a foo3"
print(foo4) // crashes with:
// RequestError: error on line 18 of module test: undefined
//  17: print(foo3)
//  18: print(foo4)
// minigrace: program test exited with code 3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions