mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 06:27:43 +00:00
templater: don't panic on PropertyPlaceholder unset error
The idea is that, if .extract() succeeded in static context, it means the property can be evaluated as constant. This will potentially eliminate expect_string_literal_with(), though I'm not too sure if it's a good idea. If needed, maybe we can extend the idea to suppress type/name resolution errors by "if(some_static_config_knob, x, y)".
This commit is contained in:
parent
32b623db67
commit
f83d1a840e
1 changed files with 5 additions and 6 deletions
|
@ -620,12 +620,11 @@ impl<O: Clone> TemplateProperty for PropertyPlaceholder<O> {
|
||||||
type Output = O;
|
type Output = O;
|
||||||
|
|
||||||
fn extract(&self) -> Result<Self::Output, TemplatePropertyError> {
|
fn extract(&self) -> Result<Self::Output, TemplatePropertyError> {
|
||||||
Ok(self
|
if let Some(value) = self.value.borrow().as_ref() {
|
||||||
.value
|
Ok(value.clone())
|
||||||
.borrow()
|
} else {
|
||||||
.as_ref()
|
Err(TemplatePropertyError("Placeholder value is not set".into()))
|
||||||
.expect("placeholder value must be set before evaluating template")
|
}
|
||||||
.clone())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue