Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions daslib/aot_cpp.das
Original file line number Diff line number Diff line change
Expand Up @@ -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()}\}");
}
Expand Down
2 changes: 1 addition & 1 deletion include/daScript/ast/compilation_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/ast/ast_derive_alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/ast/ast_infer_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -2462,7 +2467,7 @@ namespace das {
if (expr->subexpr->rtti_isVar()) {
auto evar = static_cast<ExprVar*>(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);
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions tests/language/computed_goto_out_of_block.das
Original file line number Diff line number Diff line change
@@ -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 {
}
10 changes: 10 additions & 0 deletions tests/language/failed_debug_void.das
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
options gen2
expect 30107

def v {
}

[export]
def main {
debug(v())
}
14 changes: 14 additions & 0 deletions tests/language/failed_sealed_field_redeclare.das
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
options gen2
expect 30320, 30805, 30821, 30826, 30832

class template T {
}

class e : T {
f : r<t>
sealed f : int
}

[export]
def main {
}
12 changes: 12 additions & 0 deletions tests/language/failed_typeinfo_is_argument_in_type.das
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
options gen2
expect 30110

var g_probe = 1

struct l {
f : int[typeinfo is_argument(g_probe)]
}

[export]
def main {
}
2 changes: 1 addition & 1 deletion tests/language/invalid_table_type_mix.das
Original file line number Diff line number Diff line change
Expand Up @@ -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<int&; string> // can't have table key ref
Expand Down
10 changes: 10 additions & 0 deletions tests/language/template_struct_alias_derivation.das
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
options gen2

struct template r {
def v => 0
typedef r = r<iterator<a>[ @ {0 = (0, C())}]>
}

[export]
def main {
}
Loading