mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +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;
|
||||
|
||||
fn extract(&self) -> Result<Self::Output, TemplatePropertyError> {
|
||||
Ok(self
|
||||
.value
|
||||
.borrow()
|
||||
.as_ref()
|
||||
.expect("placeholder value must be set before evaluating template")
|
||||
.clone())
|
||||
if let Some(value) = self.value.borrow().as_ref() {
|
||||
Ok(value.clone())
|
||||
} else {
|
||||
Err(TemplatePropertyError("Placeholder value is not set".into()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue