Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: evaluator on the base schema order #1733

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions kclvm/evaluator/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,22 @@ impl SchemaEvalContext {
self.optional_mapping = other.optional_mapping.clone();
self.is_sub_schema = false;
// Set lazy eval scope.
if let Some(scope) = &self.scope {
if let Some(other) = &other.scope {
if let Some(other) = &other.scope {
if let Some(scope) = &self.scope {
let mut scope = scope.borrow_mut();
let other = other.borrow();
scope.cache = other.cache.clone();
scope.levels = other.levels.clone();
scope.cal_times = other.cal_times.clone();
scope.setters = other.setters.clone();
} else {
let other = other.borrow();
self.scope = Some(Rc::new(RefCell::new(LazyEvalScope {
cache: other.cache.clone(),
levels: other.levels.clone(),
cal_times: other.cal_times.clone(),
setters: other.setters.clone(),
})))
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/grammar/schema/irrelevant_order/simple_12/main.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
schema Derived1(Base):
name: str = "1"

schema Base:
name: str
name2 = name

schema Derived2(Base):
name: str = "2"

d1 = Derived1 {}
d2 = Derived2 {}
6 changes: 6 additions & 0 deletions test/grammar/schema/irrelevant_order/simple_12/stdout.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
d1:
name: '1'
name2: '1'
d2:
name: '2'
name2: '2'
Loading