Skip to content

Allow functions without arguments - #836

Merged
mristin merged 1 commit into
mainfrom
mristin/Allow-functions-without-arguments
Oct 3, 2026
Merged

mristin merged 1 commit into
mainfrom
mristin/Allow-functions-without-arguments

Conversation

@mristin

@mristin mristin commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

The parser rejected all the functions without arguments, though a verification function can operate on constants alone, as in:

@verification
def seven_is_lucky() -> bool:
    return 7 in Lucky_numbers

We now allow them, and leave it to the existing expect_self check to reject the methods without self.

We also fix the generators for this case. TypeScript rendered function foo(): boolean: instead of function foo(): boolean {, and C++ rendered an empty line between the parentheses.

We test it with seven_is_lucky in the sets meta-model.

The parser rejected all the functions without arguments, though
a verification function can operate on constants alone, as in:

    @verification
    def seven_is_lucky() -> bool:
        return 7 in Lucky_numbers

We now allow them, and leave it to the existing ``expect_self`` check to
reject the methods without ``self``.

We also fix the generators for this case. TypeScript rendered
``function foo(): boolean:`` instead of ``function foo(): boolean {``,
and C++ rendered an empty line between the parentheses.

We test it with ``seven_is_lucky`` in the ``sets`` meta-model.
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 37155591089

Coverage increased (+0.02%) to 90.135%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 8 of 8 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 50208
Covered Lines: 45255
Line Coverage: 90.14%
Coverage Strength: 2.7 hits per line

💛 - Coveralls

@mristin
mristin merged commit 641bbe9 into main Oct 3, 2026
5 checks passed
@mristin
mristin deleted the mristin/Allow-functions-without-arguments branch October 3, 2026 21:56
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