mirror of
https://github.com/typst/typst
synced 2025-05-16 18:15:29 +08:00
Clarify the way to access functions from dictionaries (#3064)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
parent
527d63ed25
commit
39e53fcdc9
@ -110,10 +110,11 @@ impl Eval for ast::FuncCall<'_> {
|
||||
match target {
|
||||
Value::Dict(ref dict) => {
|
||||
if matches!(dict.get(&field), Ok(Value::Func(_))) {
|
||||
error.hint(
|
||||
"to call the function stored in the dictionary, \
|
||||
surround the field access with parentheses",
|
||||
);
|
||||
error.hint(eco_format!(
|
||||
"to call the function stored in the dictionary, surround \
|
||||
the field access with parentheses, e.g. `(dict.{})(..)`",
|
||||
field.as_str(),
|
||||
));
|
||||
} else {
|
||||
field_hint();
|
||||
}
|
||||
|
@ -105,11 +105,11 @@
|
||||
---
|
||||
#{
|
||||
let dict = (
|
||||
func: () => 1,
|
||||
call-me: () => 1,
|
||||
)
|
||||
// Error: 8-12 type dictionary has no method `func`
|
||||
// Hint: 8-12 to call the function stored in the dictionary, surround the field access with parentheses
|
||||
dict.func()
|
||||
// Error: 8-15 type dictionary has no method `call-me`
|
||||
// Hint: 8-15 to call the function stored in the dictionary, surround the field access with parentheses, e.g. `(dict.call-me)(..)`
|
||||
dict.call-me()
|
||||
}
|
||||
|
||||
---
|
||||
|
Loading…
x
Reference in New Issue
Block a user