Akuli / jou

Yet another programming language
MIT License
11 stars 4 forks source link

`assert True` --> weird warning #480

Open Akuli opened 6 months ago

Akuli commented 6 months ago
def main() -> int:
    assert True
    return 0

this outputs:

compiler warning for file "asd.jou", line 2: this code will never run

The error message is misleading. The code does run, it just never fails the assert. Something like condition of 'assert' is always True would be much better.

When the error message says "this code", it means the code for handling failed assertions. The code above is equivalent to:

import "stdlib/_assert_fail.jou"

def main() -> int:
    if not True:
        _jou_assert_fail("True", "asd.jou", 2)
    return 0
littlewhitecloud commented 6 months ago

Or the assert statement doesn't make sense here?

Moosems commented 6 months ago

Misleading yes, but why would you be doing assert True? I could understand assert True == True and the former giving an error like assert lacks conditional statement.