diff --git a/crates/typst/src/eval/call.rs b/crates/typst/src/eval/call.rs index e15f2c335..3bdd9a462 100644 --- a/crates/typst/src/eval/call.rs +++ b/crates/typst/src/eval/call.rs @@ -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(); } diff --git a/tests/typ/compiler/dict.typ b/tests/typ/compiler/dict.typ index e66d8099e..cba2b6184 100644 --- a/tests/typ/compiler/dict.typ +++ b/tests/typ/compiler/dict.typ @@ -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() } ---