mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-21 02:08:56 +08:00
🐛 fix segfault in var x = (var a,b) = (1,2)
This commit is contained in:
+13
-3
@@ -118,7 +118,11 @@ bool parse::check_tuple() {
|
||||
}
|
||||
|
||||
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) {
|
||||
return true;
|
||||
} else if (type==expr_type::ast_def) {
|
||||
@@ -154,7 +158,11 @@ bool parse::check_special_call() {
|
||||
}
|
||||
|
||||
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 ||
|
||||
type==expr_type::ast_forei ||
|
||||
type==expr_type::ast_while ||
|
||||
@@ -627,7 +635,9 @@ expr* parse::scalar() {
|
||||
return null();
|
||||
}
|
||||
// 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);
|
||||
call_node->set_first(node);
|
||||
while(is_call(toks[ptr].type)) {
|
||||
|
||||
@@ -13,6 +13,7 @@ var content = [];
|
||||
var log_cache = "";
|
||||
|
||||
println("Nasal: This is experimental REPL");
|
||||
println("Tips : \";\" is automatically added at the end of the input line.");
|
||||
help();
|
||||
|
||||
var count_bracket = func(line) {
|
||||
|
||||
Reference in New Issue
Block a user