History

accept "ret" for functions with a return type

This happens to be needed for C. The standard mandates that a return value is used if the caller uses it. Surprisingly, if the return "value" is not used, the callee can use "return;". A better solution is to add an "undef" value and return it, "undef" would also have other use cases for compiling C.

Quentin Carbonneaux committed 10 years ago

Commit fd9c2e01 parent 09192cd1 file · +4 −2Browse files

Unified · Split

parse.c+4−2
@@ -545,10 +545,12 @@ parseline(PState ps) · 544 unmodified lines
545545 Jrets, Jretd,
546546 Jretc, Jret0
547547 }[rcls];
548− if (rcls < 5) {
548+ if (peek() == Tnl)
549+ curb->jmp.type = Jret0;
550+ else if (rcls < 5) {
549551 r = parseref();
550552 if (req(r, R))
551− err("return value expected");
553+ err("invalid return value");
552554 curb->jmp.arg = r;
553555 }
554556 goto Close;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t