Skip to content

compiler: add support for shorthand method declarations#387

Open
jow- wants to merge 1 commit into
masterfrom
syntax-method-support
Open

compiler: add support for shorthand method declarations#387
jow- wants to merge 1 commit into
masterfrom
syntax-method-support

Conversation

@jow-

@jow- jow- commented Mar 23, 2026

Copy link
Copy Markdown
Owner

Add support for ES6-style shorthand method syntax in object literals. This allows declaring methods without the function keyword:

obj = {
    foo() { return 42; },
    add(a, b) { return a + b; },
    sum(...args) { ... }
};

Add support for ES6-style shorthand method syntax in object literals.
This allows declaring methods without the `function` keyword:

    obj = {
        foo() { return 42; },
        add(a, b) { return a + b; },
        sum(...args) { ... }
    };

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
@systemcrash

Copy link
Copy Markdown
Contributor

Is this ready for prime-time?

@systemcrash

Copy link
Copy Markdown
Contributor

I get

ucode/compiler.c:2136:10: warning: unused variable 'slot' [-Wunused-variable]
 2136 |         ssize_t slot;
      |                 ^~~~
1 warning generated.

other than that test complete OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants