Skip to content

Commit

Permalink
Fix(kclvm-codegen): fix schema back ref. (#232)
Browse files Browse the repository at this point in the history
* Fix(kclvm-codegen): fix schema back ref.

fix schema back reference exception.

issue #231

* fix mistake
  • Loading branch information
zong-zhe committed Oct 11, 2022
1 parent 1a5ddd7 commit 93ee39e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kclvm/compiler/src/codegen/llvm/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ impl<'ctx> LLVMCodeGenContext<'ctx> {
}
ast::Stmt::Schema(schema_stmt) => {
self.predefine_global_types(&schema_stmt.name.node);
self.walk_schema_stmt(schema_stmt)
.expect(kcl_error::COMPILE_ERROR_MSG);
}
ast::Stmt::Rule(rule_stmt) => {
self.predefine_global_types(&rule_stmt.name.node);
self.walk_rule_stmt(rule_stmt)
.expect(kcl_error::COMPILE_ERROR_MSG);
}
_ => {}
};
Expand Down
5 changes: 5 additions & 0 deletions test/grammar/schema/back_ref/back_ref_1.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
x0 = Person {}

schema Person:
name: str = "kcl"
age: int = 1
3 changes: 3 additions & 0 deletions test/grammar/schema/back_ref/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
x0:
name: kcl
age: 1

0 comments on commit 93ee39e

Please sign in to comment.