GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Nested unary negation `-(-a)` emits `--a`, which Lua parses as a comment · Issue #1733 · TypeScriptToLua/TypeScriptToLua

Nested unary negation -(-a) emits --a, which Lua parses as a comment #1733

New issue
Copy link
New issue
Copy link
Closed
#1736
Closed
Nested unary negation -(-a) emits --a, which Lua parses as a comment#1733
#1736
Copy link

Description

@trackoor
trackoor
opened on Nov 7, 2026
Issue body actions

In typescript-to-lua 1.37.1, transpiling a nested unary negation drops the parentheses and emits two consecutive - characters without a space (--), which Lua parses as a line comment.

let a = 5;
const b = -(-a);
console.log(b);

This compiles to:

a = 5
b = --a
print(b)

Because --a is treated as a comment to the end of the line, Lua executes b = print(b), printing nil instead of 5 (or failing with a syntax error when nothing follows on the next line).

printUnaryExpression only parenthesizes operands with strictly lower operator precedence, so nested unary minus operators are printed directly adjacent instead of -(-a) or - -a.

Credit: https://ucsbplse.github.io/

Activity

  1. Perryvw
    closed this as completedin 88d0001on Nov 12, 2026
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

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.