Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa committed Sep 6, 2024
1 parent c4b9fbd commit 3e742d9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion kclvm/sema/src/advanced_resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ mod tests {
fn test_schema_circle_dep() {
let sess = Arc::new(ParseSession::default());

let path = "src/advanced_resolver/test_data/circle_dep.k"
let path = "src/advanced_resolver/test_data/circle_dep/circle_dep.k"
.to_string()
.replace("/", &std::path::MAIN_SEPARATOR.to_string());
let mut program = load_program(sess.clone(), &[&path], None, None)
Expand Down
8 changes: 0 additions & 8 deletions kclvm/sema/src/advanced_resolver/test_data/circle_dep.k

This file was deleted.

14 changes: 14 additions & 0 deletions kclvm/sema/src/advanced_resolver/test_data/circle_dep/circle_dep.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
schema A(A):
name: str

schema B(C):
name: str

schema C(B):
name: str


schema D:
mixin [D]

mixin D for D
14 changes: 9 additions & 5 deletions kclvm/sema/src/core/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,11 +1239,15 @@ impl SchemaSymbol {

pub fn get_parents(&self, data: &SymbolData, parents: &mut Vec<SymbolRef>) {
if let Some(parent_schema_ref) = self.parent_schema {
if let Some(parent_schema) = data.get_schema_symbol(parent_schema_ref) {
// circular reference
if !parents.contains(&parent_schema_ref) {
parents.push(parent_schema_ref);
parent_schema.get_parents(data, parents);
if let Some(parent_schema) = data.get_symbol(parent_schema_ref) {
if let Some(schema_def) = parent_schema.get_definition() {
if let Some(parent_schema) = data.get_schema_symbol(schema_def) {
// circular reference
if !parents.contains(&schema_def) {
parents.push(schema_def);
parent_schema.get_parents(data, parents);
}
}
}
}
}
Expand Down

0 comments on commit 3e742d9

Please sign in to comment.