Skip to content

[feat] warn if no output predicate exists #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions godel-script/godel-frontend/src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ void engine::run_souffle(const std::string& souffle_content,
argv.push_back("--index-stats");
}

// magic set, it's not suggested to use it on all the predicates
// argv.push_back("--magic-transform=*");

// need latest version of souffle to make it more efficient
// argv.push_back("--jobs=4");

// enable souffle auto schedule, for experimental use only
// argv.push_back("--auto-schedule=souffle.prof.log");

Expand Down
29 changes: 26 additions & 3 deletions godel-script/godel-frontend/src/ir/ir_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,23 @@ void ir_gen::emit_schema_get_field() {
);
call->add_arg(lir::inst_value_t::variable("self"));
call->add_arg(lir::inst_value_t::default_value());

// enable particular index
// for z in pred(_, _, z, _, _)
// it's better to use pred(x, y, z, _, _) to auto generate index in souffle
int count = 0;
bool reach_field = false;
for(const auto& f : sc.second.ordered_fields) {
call->add_arg(f==field?
lir::inst_value_t::variable("ret?result"):
lir::inst_value_t::default_value()
if (f == field) {
reach_field = true;
}
call->add_arg(f==field
? lir::inst_value_t::variable("ret?result")
: reach_field
? lir::inst_value_t::default_value()
: lir::inst_value_t::variable("?" + std::to_string(count))
);
++count;
}
rule_impl->get_block()->add_new_content(call);
}
Expand Down Expand Up @@ -1102,6 +1114,16 @@ void ir_gen::report_ignored_DO_schema_data_constraint() {
err.warn_ignored_DO_schema(ignored_DO_schema);
}

void ir_gen::report_no_output_predicate() {
if (irc.souffle_output.size() || irc.annotated_output.size()) {
return;
}
err.warn(
"no output predicate is found, "
"execution will not generate any outputs or output files."
);
}

bool ir_gen::visit_number_literal(number_literal* node) {
value_stack.push_back({
data_kind::literal,
Expand Down Expand Up @@ -2488,6 +2510,7 @@ void ir_gen::generate(const cli::configure& config, ast_root* root) {
root->accept(this);

report_ignored_DO_schema_data_constraint();
report_no_output_predicate();
}

}
1 change: 1 addition & 0 deletions godel-script/godel-frontend/src/ir/ir_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class ir_gen: public ast_visitor {
private:
std::unordered_set<std::string> ignored_DO_schema;
void report_ignored_DO_schema_data_constraint();
void report_no_output_predicate();

private:
bool visit_number_literal(number_literal*) override;
Expand Down
5 changes: 3 additions & 2 deletions godel-script/godel-frontend/src/semantic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2359,7 +2359,7 @@ bool semantic::check_single_argument(expr* argument, const symbol& param) {
}

// check type match
if (param!=expr_infer.type) {
if (param != expr_infer.type && !expr_infer.type.is_err()) {
err.err(argument->get_location(),
"expected \"" + param.full_path_name() +
"\" but get \"" + expr_infer.type.full_path_name() + "\"."
Expand Down Expand Up @@ -2864,7 +2864,8 @@ void semantic::query_check(query_decl* node) {
.is_set = false
};

if (initial_infer.type!=from_variable_type) {
if (initial_infer.type != from_variable_type &&
!initial_infer.type.is_err()) {
err.err(i->get_init_value()->get_location(),
"expected \"" + from_variable_type.full_path_name() +
"\" but get \"" + initial_infer.type.full_path_name() +
Expand Down
Loading