mirror of
https://github.com/typst/typst
synced 2025-05-17 02:25:27 +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 {
|
match target {
|
||||||
Value::Dict(ref dict) => {
|
Value::Dict(ref dict) => {
|
||||||
if matches!(dict.get(&field), Ok(Value::Func(_))) {
|
if matches!(dict.get(&field), Ok(Value::Func(_))) {
|
||||||
error.hint(
|
error.hint(eco_format!(
|
||||||
"to call the function stored in the dictionary, \
|
"to call the function stored in the dictionary, surround \
|
||||||
surround the field access with parentheses",
|
the field access with parentheses, e.g. `(dict.{})(..)`",
|
||||||
);
|
field.as_str(),
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
field_hint();
|
field_hint();
|
||||||
}
|
}
|
||||||
|
@ -105,11 +105,11 @@
|
|||||||
---
|
---
|
||||||
#{
|
#{
|
||||||
let dict = (
|
let dict = (
|
||||||
func: () => 1,
|
call-me: () => 1,
|
||||||
)
|
)
|
||||||
// Error: 8-12 type dictionary has no method `func`
|
// Error: 8-15 type dictionary has no method `call-me`
|
||||||
// Hint: 8-12 to call the function stored in the dictionary, surround the field access with parentheses
|
// Hint: 8-15 to call the function stored in the dictionary, surround the field access with parentheses, e.g. `(dict.call-me)(..)`
|
||||||
dict.func()
|
dict.call-me()
|
||||||
}
|
}
|
||||||
|
|
||||||
---
|
---
|
||||||
|
Loading…
x
Reference in New Issue
Block a user