diff options
| author | Simon Rask <33556894+SimonRask@users.noreply.github.com> | 2023-08-21 16:26:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-21 16:26:05 +0200 |
| commit | 046029b1e21324c3b10b03423d9bd297b4eafe8f (patch) | |
| tree | d9c9dccae7b3a3eff545d80820b6802a9a73ea03 /crates | |
| parent | f6a4b8f97babf84913a4583be14059a574bd8bc8 (diff) | |
Add hint for missing method error for dictionary where a field with a function is present (#1922)
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst/src/eval/methods.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/typst/src/eval/methods.rs b/crates/typst/src/eval/methods.rs index 6df504b5..6127a807 100644 --- a/crates/typst/src/eval/methods.rs +++ b/crates/typst/src/eval/methods.rs @@ -173,7 +173,17 @@ pub fn call( "keys" => dict.keys().into_value(), "values" => dict.values().into_value(), "pairs" => dict.pairs().into_value(), - _ => return missing(), + _ => { + return if matches!(dict.at(method, None), Ok(Value::Func(_))) { + Err(missing_method(name, method)) + .hint(eco_format!( + "to call the function stored in the dictionary, surround the field access with parentheses" + )) + .at(span) + } else { + missing() + } + } }, Value::Func(func) => match method { |
