Mercurial Hosting > luan
changeset 1560:33a53c43e2f7
handle unreachable statement
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 22 Oct 2020 00:33:04 -0600 |
parents | 153ea3b7afaf |
children | e1a13e707bf3 |
files | src/luan/impl/LuanParser.java |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
diff -r 153ea3b7afaf -r 33a53c43e2f7 src/luan/impl/LuanParser.java --- a/src/luan/impl/LuanParser.java Thu Oct 22 00:25:40 2020 -0600 +++ b/src/luan/impl/LuanParser.java Thu Oct 22 00:33:04 2020 -0600 @@ -1134,7 +1134,14 @@ stmt.addAll( block ); stmt.hasReturn = block.hasReturn; Expr fnDef = newFnExp(stmt,name); - RequiredEnd("end_function"); +// RequiredEnd("end_function"); + if( !Keyword("end") && !Keyword("end_function") ) { + if( stmt.hasReturn && !parser.endOfInput() ) { + throw parser.exception("unreachable statement"); + } else { + throw parser.exception("'end_function' or 'end' expected"); + } + } frame = frame.parent; return parser.success(fnDef); }