diff --git a/daslib/aot_cpp.das b/daslib/aot_cpp.das index 8e3e21fbd3..8e862c8309 100644 --- a/daslib/aot_cpp.das +++ b/daslib/aot_cpp.das @@ -1891,16 +1891,18 @@ class public CppAot : AstVisitor { def override visitExprGoto(var that : ExprGoto?) : ExpressionPtr { if (that.subexpr != null) { write(*ss, ") \{\n"); - scopes |> reverse(); - for (blk in scopes) { + var si = length(scopes) - 1; + while (si >= 0) { + let blk = scopes[si]; for (ex in blk.list) { if (ex is ExprLabel) { let lab = ex as ExprLabel; write(*ss, "{tabs()}case {lab.labelName}: goto label_{lab.labelName};\n"); } } + break if (blk.blockFlags.isClosure); + si--; } - scopes |> reverse(); write(*ss, "{tabs()}default: __context__->throw_error(\"invalid label\");\n"); write(*ss, "{tabs()}\}"); } diff --git a/include/daScript/ast/compilation_errors.h b/include/daScript/ast/compilation_errors.h index 199c0b4993..f1da01ed65 100644 --- a/include/daScript/ast/compilation_errors.h +++ b/include/daScript/ast/compilation_errors.h @@ -106,7 +106,7 @@ namespace das , invalid_argument = 30104 // 6 site(s) , invalid_argument_global = 30105 // 4 site(s) , invalid_argument_name = 30106 // 3 site(s) - , invalid_argument_type = 30107 // 3 site(s) + , invalid_argument_type = 30107 // 4 site(s) , invalid_array = 30108 // 6 site(s) , invalid_array_dimension = 30109 // 5 site(s) , invalid_array_dimension_type = 30110 // 1 site(s) diff --git a/src/ast/ast_derive_alias.cpp b/src/ast/ast_derive_alias.cpp index b3f032b440..06f1681d38 100644 --- a/src/ast/ast_derive_alias.cpp +++ b/src/ast/ast_derive_alias.cpp @@ -321,6 +321,9 @@ namespace das { var->aliasesResolved = isPermanent; return true; } + virtual bool canVisitStructure ( Structure * st ) override { + return !st->isTemplate; + } virtual bool canVisitFunction ( Function * fun ) override { if ( fun->stub ) return false; if ( fun->isTemplate ) return false; diff --git a/src/ast/ast_infer_type.cpp b/src/ast/ast_infer_type.cpp index 671221cab8..c6791bd6f2 100644 --- a/src/ast/ast_infer_type.cpp +++ b/src/ast/ast_infer_type.cpp @@ -1604,6 +1604,11 @@ namespace das { error("debug comment must be string constant", "", "", expr->at, CompilationError::invalid_debug_comment_type); } + if (expr->arguments[0]->type->isVoid()) { + error("void type is not allowed as argument", "", "", + expr->at, CompilationError::invalid_argument_type); + return Visitor::visit(expr); + } TypeDecl::clone(expr->type, expr->arguments[0]->type); return Visitor::visit(expr); } @@ -2462,7 +2467,7 @@ namespace das { if (expr->subexpr->rtti_isVar()) { auto evar = static_cast(expr->subexpr); reportAstChanged(); - return new ExprConstBool(expr->at, func->findArgument(evar->name) != nullptr); + return new ExprConstBool(expr->at, func && func->findArgument(evar->name) != nullptr); } else { reportAstChanged(); return new ExprConstBool(expr->at, false); diff --git a/src/parser/parser_impl.cpp b/src/parser/parser_impl.cpp index 3525403ffb..91dc287566 100644 --- a/src/parser/parser_impl.cpp +++ b/src/parser/parser_impl.cpp @@ -455,7 +455,7 @@ namespace das { oldFd->init = pDecl->pInit; pDecl->pInit = nullptr; } } - oldFd->parentType = oldFd->type->isAuto(); + oldFd->parentType = oldFd->inherited && oldFd->type->isAuto(); oldFd->privateField = pDecl->isPrivate; oldFd->sealed = pDecl->sealed; oldFd->implemented = true; diff --git a/tests/language/computed_goto_out_of_block.das b/tests/language/computed_goto_out_of_block.das new file mode 100644 index 0000000000..53bc5efe42 --- /dev/null +++ b/tests/language/computed_goto_out_of_block.das @@ -0,0 +1,18 @@ +options gen2 + +def label_target : int { + return 6 +} + +[export] +def computed_goto_in_a_captured_block { + invoke($ { + goto label_target() + }) + label 6: + pass +} + +[export] +def main { +} diff --git a/tests/language/failed_debug_void.das b/tests/language/failed_debug_void.das new file mode 100644 index 0000000000..8a20e4e432 --- /dev/null +++ b/tests/language/failed_debug_void.das @@ -0,0 +1,10 @@ +options gen2 +expect 30107 + +def v { +} + +[export] +def main { + debug(v()) +} diff --git a/tests/language/failed_sealed_field_redeclare.das b/tests/language/failed_sealed_field_redeclare.das new file mode 100644 index 0000000000..93e8cc5ff6 --- /dev/null +++ b/tests/language/failed_sealed_field_redeclare.das @@ -0,0 +1,14 @@ +options gen2 +expect 30320, 30805, 30821, 30826, 30832 + +class template T { +} + +class e : T { + f : r + sealed f : int +} + +[export] +def main { +} diff --git a/tests/language/failed_typeinfo_is_argument_in_type.das b/tests/language/failed_typeinfo_is_argument_in_type.das new file mode 100644 index 0000000000..9efbc95099 --- /dev/null +++ b/tests/language/failed_typeinfo_is_argument_in_type.das @@ -0,0 +1,12 @@ +options gen2 +expect 30110 + +var g_probe = 1 + +struct l { + f : int[typeinfo is_argument(g_probe)] +} + +[export] +def main { +} diff --git a/tests/language/invalid_table_type_mix.das b/tests/language/invalid_table_type_mix.das index 52e4eafc4e..ed79abf77f 100644 --- a/tests/language/invalid_table_type_mix.das +++ b/tests/language/invalid_table_type_mix.das @@ -2,7 +2,7 @@ // verifies compiler rejects ref keys, non-hashable keys (array), // and void local variables options gen2 -expect 30202, 30248, 30254 // invalid_table_type +expect 30107, 30202, 30248, 30254 // invalid_table_type def test { let a : table // can't have table key ref diff --git a/tests/language/template_struct_alias_derivation.das b/tests/language/template_struct_alias_derivation.das new file mode 100644 index 0000000000..10356bab03 --- /dev/null +++ b/tests/language/template_struct_alias_derivation.das @@ -0,0 +1,10 @@ +options gen2 + +struct template r { + def v => 0 + typedef r = r[ @ {0 = (0, C())}]> +} + +[export] +def main { +}