From bcf790f6da249356fb3684f58219a5c5982b87af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=95=E5=B1=B1?= Date: Tue, 7 Jan 2025 14:50:07 +0800 Subject: [PATCH 1/2] fix name mangling bug --- godel-script/godel-frontend/src/ir/name_mangling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godel-script/godel-frontend/src/ir/name_mangling.cpp b/godel-script/godel-frontend/src/ir/name_mangling.cpp index bb8f166..8a221ba 100644 --- a/godel-script/godel-frontend/src/ir/name_mangling.cpp +++ b/godel-script/godel-frontend/src/ir/name_mangling.cpp @@ -127,7 +127,7 @@ std::string rule_mangle(const std::string& name) { prefix = "GT_"; } else if (starts_with(name, "typecheck_")) { // typecheck_xxx -> TC_xxx - temp = name.substr(11); + temp = name.substr(10); prefix = "TC_"; } else { // std::cerr << "unknown rule name: " << name << std::endl; From 354f07d0e46ae7329f63bd2300f4ae097de3dda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=95=E5=B1=B1?= Date: Tue, 7 Jan 2025 16:27:28 +0800 Subject: [PATCH 2/2] fix #90 issue --- .../godel-frontend/src/sema/ungrounded_checker.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/godel-script/godel-frontend/src/sema/ungrounded_checker.cpp b/godel-script/godel-frontend/src/sema/ungrounded_checker.cpp index 07c31b3..276d6a7 100644 --- a/godel-script/godel-frontend/src/sema/ungrounded_checker.cpp +++ b/godel-script/godel-frontend/src/sema/ungrounded_checker.cpp @@ -581,11 +581,18 @@ bool ungrounded_parameter_checker::is_schema_get_primary_key(call_root* node) { if (node->get_call_head()->get_first_expression()->get_ast_class()!=ast_class::ac_identifier) { return false; } + const auto& head_type = node->get_call_head()->get_resolve(); + // head type should not be global symbol or data-set type if (head_type.is_global || head_type.type.is_set) { return false; } - if (node->get_call_chain().size()!=1) { + + // schema get primary key pattern may be: + // 1. schema.primary_key + // 2. schema.primary_key.other_calls() + // so size should be >= 1 + if (node->get_call_chain().size()<1) { return false; } 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) { return false; } const auto key = node->get_call_chain()[0]->get_field_name()->get_name(); + // check if the field is primary key return sc.fields.count(key) && sc.fields.at(key).primary; }