Skip to content

Commit

Permalink
fix: evaluator on the base schema order (#1733)
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy authored Nov 4, 2024
1 parent 35b56d8 commit 481eed9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
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'

0 comments on commit 481eed9

Please sign in to comment.