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

Showing the changes to parse.c (1 of 1 file). Show all

Unified · Split

parse.c+4−2
@@ -545,10 +545,12 @@ parseline(PState ps) · 544 unmodified lines
545 Jrets, Jretd,545 Jrets, Jretd,
546 Jretc, Jret0546 Jretc, Jret0
547 }[rcls];547 }[rcls];
548 if (rcls < 5) {548 if (peek() == Tnl)
549 curb->jmp.type = Jret0;
550 else if (rcls < 5) {
549 r = parseref();551 r = parseref();
550 if (req(r, R))552 if (req(r, R))
551 err("return value expected");553 err("invalid return value");
552 curb->jmp.arg = r;554 curb->jmp.arg = r;
553 }555 }
554 goto Close;556 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