Skip to content

Consider making ; a statement separator instead of expression list separator #464

Description

@leafo

Current Behavior

Currently, ; is only valid as an alternative to , in a few specific contexts (ExpListLow):

  • Return statements: return a; b
  • Assignments: x = a; b
  • Exports: export x = a; b

This was introduced in 2011 as a "value separator" to help disambiguate from function calls, but it's an obscure feature that few users likely know about or use.

Proposal

Remove the current ; behavior and repurpose it as a statement separator, allowing multiple statements on a single line while preserving the current indentation level. This would align with Lua's syntax.

Examples

-- Simple one-liners
x = 1; y = 2

-- Short related statements
i += 1; j += 1

In block contexts

The semicolon would maintain the current indentation:

if condition
  setup!; run!; cleanup!

Equivalent to:

if condition
  setup!
  run!
  cleanup!

Breaking Changes

This removes the ability to use ; as a value separator in return/assignment/export. Users would need to switch to ,:

-- No longer valid
return a; b

-- Use instead
return a, b

This usage is likely rare since , works identically and is more conventional.

Metadata

Metadata

Assignees

No one assigned

    Labels

    syntax proposalProposed changes to MoonScript syntax

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions