Skip to content

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

@wcjohnson

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.

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