Skip to content

Commit 8fe1a45

Browse files
authored
Merge pull request #91 from codefuse-ai/lhk_dev
[fix] fix #90 self not constraint bug
2 parents 7469990 + 354f07d commit 8fe1a45

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

godel-script/godel-frontend/src/ir/name_mangling.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ std::string rule_mangle(const std::string& name) {
127127
prefix = "GT_";
128128
} else if (starts_with(name, "typecheck_")) {
129129
// typecheck_xxx -> TC_xxx
130-
temp = name.substr(11);
130+
temp = name.substr(10);
131131
prefix = "TC_";
132132
} else {
133133
// std::cerr << "unknown rule name: " << name << std::endl;

godel-script/godel-frontend/src/sema/ungrounded_checker.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,18 @@ bool ungrounded_parameter_checker::is_schema_get_primary_key(call_root* node) {
581581
if (node->get_call_head()->get_first_expression()->get_ast_class()!=ast_class::ac_identifier) {
582582
return false;
583583
}
584+
584585
const auto& head_type = node->get_call_head()->get_resolve();
586+
// head type should not be global symbol or data-set type
585587
if (head_type.is_global || head_type.type.is_set) {
586588
return false;
587589
}
588-
if (node->get_call_chain().size()!=1) {
590+
591+
// schema get primary key pattern may be:
592+
// 1. schema.primary_key
593+
// 2. schema.primary_key.other_calls()
594+
// so size should be >= 1
595+
if (node->get_call_chain().size()<1) {
589596
return false;
590597
}
591598
const auto name = head_type.type.full_path_name_without_set();
@@ -602,6 +609,7 @@ bool ungrounded_parameter_checker::is_schema_get_primary_key(call_root* node) {
602609
return false;
603610
}
604611
const auto key = node->get_call_chain()[0]->get_field_name()->get_name();
612+
// check if the field is primary key
605613
return sc.fields.count(key) && sc.fields.at(key).primary;
606614
}
607615

0 commit comments

Comments
 (0)