mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-26 12:59:05 +08:00
🐛 fix segfault in var x = (var a,b) = (1,2)
This commit is contained in:
+11
-1
@@ -118,6 +118,10 @@ bool parse::check_tuple() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool parse::check_func_end(expr* node) {
|
bool parse::check_func_end(expr* node) {
|
||||||
|
// avoid error parse caused nullptr return value
|
||||||
|
if (!node) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
auto type = node->get_type();
|
auto type = node->get_type();
|
||||||
if (type==expr_type::ast_func) {
|
if (type==expr_type::ast_func) {
|
||||||
return true;
|
return true;
|
||||||
@@ -154,6 +158,10 @@ bool parse::check_special_call() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool parse::need_semi_check(expr* node) {
|
bool parse::need_semi_check(expr* node) {
|
||||||
|
// avoid error parse caused nullptr return value
|
||||||
|
if (!node) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
auto type = node->get_type();
|
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 ||
|
||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user