Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bcb32ff

Browse files
authored
Merge pull request #120 from codefuse-ai/lhk_dev
[feat] warn if no output predicate exists
2 parents 236a901 + 20c5e3b commit bcb32ff

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

‎godel-script/godel-frontend/src/engine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ void engine::run_souffle(const std::string& souffle_content,
400400
argv.push_back("--index-stats");
401401
}
402402

403+
// magic set, it's not suggested to use it on all the predicates
404+
// argv.push_back("--magic-transform=*");
405+
406+
// need latest version of souffle to make it more efficient
407+
// argv.push_back("--jobs=4");
408+
403409
// enable souffle auto schedule, for experimental use only
404410
// argv.push_back("--auto-schedule=souffle.prof.log");
405411

‎godel-script/godel-frontend/src/ir/ir_gen.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,23 @@ void ir_gen::emit_schema_get_field() {
538538
);
539539
call->add_arg(lir::inst_value_t::variable("self"));
540540
call->add_arg(lir::inst_value_t::default_value());
541+
542+
// enable particular index
543+
// for z in pred(_, _, z, _, _)
544+
// it's better to use pred(x, y, z, _, _) to auto generate index in souffle
545+
int count = 0;
546+
bool reach_field = false;
541547
for(const auto& f : sc.second.ordered_fields) {
542-
call->add_arg(f==field?
543-
lir::inst_value_t::variable("ret?result"):
544-
lir::inst_value_t::default_value()
548+
if (f == field) {
549+
reach_field = true;
550+
}
551+
call->add_arg(f==field
552+
? lir::inst_value_t::variable("ret?result")
553+
: reach_field
554+
? lir::inst_value_t::default_value()
555+
: lir::inst_value_t::variable("?" + std::to_string(count))
545556
);
557+
++count;
546558
}
547559
rule_impl->get_block()->add_new_content(call);
548560
}
@@ -1102,6 +1114,16 @@ void ir_gen::report_ignored_DO_schema_data_constraint() {
11021114
err.warn_ignored_DO_schema(ignored_DO_schema);
11031115
}
11041116

1117+
void ir_gen::report_no_output_predicate() {
1118+
if (irc.souffle_output.size() || irc.annotated_output.size()) {
1119+
return;
1120+
}
1121+
err.warn(
1122+
"no output predicate is found, "
1123+
"execution will not generate any outputs or output files."
1124+
);
1125+
}
1126+
11051127
bool ir_gen::visit_number_literal(number_literal* node) {
11061128
value_stack.push_back({
11071129
data_kind::literal,
@@ -2488,6 +2510,7 @@ void ir_gen::generate(const cli::configure& config, ast_root* root) {
24882510
root->accept(this);
24892511

24902512
report_ignored_DO_schema_data_constraint();
2513+
report_no_output_predicate();
24912514
}
24922515

24932516
}

‎godel-script/godel-frontend/src/ir/ir_gen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ class ir_gen: public ast_visitor {
202202
private:
203203
std::unordered_set<std::string> ignored_DO_schema;
204204
void report_ignored_DO_schema_data_constraint();
205+
void report_no_output_predicate();
205206

206207
private:
207208
bool visit_number_literal(number_literal*) override;

‎godel-script/godel-frontend/src/semantic.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ bool semantic::check_single_argument(expr* argument, const symbol& param) {
23592359
}
23602360

23612361
// check type match
2362-
if (param!=expr_infer.type) {
2362+
if (param != expr_infer.type && !expr_infer.type.is_err()) {
23632363
err.err(argument->get_location(),
23642364
"expected \"" + param.full_path_name() +
23652365
"\" but get \"" + expr_infer.type.full_path_name() + "\"."
@@ -2864,7 +2864,8 @@ void semantic::query_check(query_decl* node) {
28642864
.is_set = false
28652865
};
28662866

2867-
if (initial_infer.type!=from_variable_type) {
2867+
if (initial_infer.type != from_variable_type &&
2868+
!initial_infer.type.is_err()) {
28682869
err.err(i->get_init_value()->get_location(),
28692870
"expected \"" + from_variable_type.full_path_name() +
28702871
"\" but get \"" + initial_infer.type.full_path_name() +

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /