🐛 fix segfault in `var x = (var a,b) = (1,2)`
This commit is contained in:
parent
88b039a82e
commit
98b0086656
|
@ -118,7 +118,11 @@ bool parse::check_tuple() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse::check_func_end(expr* node) {
|
bool parse::check_func_end(expr* node) {
|
||||||
auto type=node->get_type();
|
// avoid error parse caused nullptr return value
|
||||||
|
if (!node) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto type = node->get_type();
|
||||||
if (type==expr_type::ast_func) {
|
if (type==expr_type::ast_func) {
|
||||||
return true;
|
return true;
|
||||||
} else if (type==expr_type::ast_def) {
|
} else if (type==expr_type::ast_def) {
|
||||||
|
@ -154,7 +158,11 @@ bool parse::check_special_call() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse::need_semi_check(expr* node) {
|
bool parse::need_semi_check(expr* node) {
|
||||||
auto type=node->get_type();
|
// avoid error parse caused nullptr return value
|
||||||
|
if (!node) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
auto type = node->get_type();
|
||||||
if (type==expr_type::ast_for ||
|
if (type==expr_type::ast_for ||
|
||||||
type==expr_type::ast_forei ||
|
type==expr_type::ast_forei ||
|
||||||
type==expr_type::ast_while ||
|
type==expr_type::ast_while ||
|
||||||
|
@ -348,7 +356,7 @@ expr* parse::expression() {
|
||||||
case tok::cont: return continue_expression();
|
case tok::cont: return continue_expression();
|
||||||
case tok::brk: return break_expression();
|
case tok::brk: return break_expression();
|
||||||
case tok::ret: return return_expression();
|
case tok::ret: return return_expression();
|
||||||
case tok::semi: break;
|
case tok::semi: break;
|
||||||
default:
|
default:
|
||||||
die(thisspan, "incorrect token <"+toks[ptr].str+">");
|
die(thisspan, "incorrect token <"+toks[ptr].str+">");
|
||||||
next();
|
next();
|
||||||
|
@ -627,7 +635,9 @@ expr* parse::scalar() {
|
||||||
return null();
|
return null();
|
||||||
}
|
}
|
||||||
// check call and avoid ambiguous syntax
|
// check call and avoid ambiguous syntax
|
||||||
if (is_call(toks[ptr].type) && !(lookahead(tok::lcurve) && toks[ptr+1].type==tok::var)) {
|
// i don't know why using `&& !(lookahead(tok::lcurve) && toks[ptr+1].type==tok::var)`
|
||||||
|
// here, maybe we'll find the reason XD
|
||||||
|
if (is_call(toks[ptr].type)) {
|
||||||
auto call_node = new call_expr(toks[ptr].loc);
|
auto call_node = new call_expr(toks[ptr].loc);
|
||||||
call_node->set_first(node);
|
call_node->set_first(node);
|
||||||
while(is_call(toks[ptr].type)) {
|
while(is_call(toks[ptr].type)) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ var content = [];
|
||||||
var log_cache = "";
|
var log_cache = "";
|
||||||
|
|
||||||
println("Nasal: This is experimental REPL");
|
println("Nasal: This is experimental REPL");
|
||||||
|
println("Tips : \";\" is automatically added at the end of the input line.");
|
||||||
help();
|
help();
|
||||||
|
|
||||||
var count_bracket = func(line) {
|
var count_bracket = func(line) {
|
||||||
|
|
Loading…
Reference in New Issue