Skip to content

[compiler] Conditional expressions probably need to return undefined by default #45

Open

Description

@wcjohnson

Problem

x = if false: 1
// x === null

y = (->
  if false:
    1
)()
// y === undefined

Wrapping an expression in a function had better not change its value.

Proposed Solution

While trying to work around JavaScript's proliferation of distinct-yet-falsy values may be noble in spirit, the fact that JavaScript returns undefined by default basically forces LSC to do the same for consistency's sake. I think unprovided branches of conditional expressions (if, and possibly match if it doesn't throw-on-else) should be returning undefined to match up with JavaScript core function behavior.

Activity

  1. rattrayalex commented on Sep 6, 2017

    @rattrayalex
    Contributor

    Yeah, agreed. It's a bummer, but it needs to be undefined. Well said.

  2. added a commit that references this issue on Oct 3, 2017
  3. added 2 commits that reference this issue on Oct 25, 2017
  4. added a commit that references this issue on May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions