Why is there an unexpected argument error when using the dictionary at() function?

Hi

I am missing something?

#let input = dictionary(sys).at("inputs").at("INPUT_KEY", "default")
error: unexpected argument
  ┌─ file.typ:5:60
  │
5 │ #let input = dictionary(sys).at("inputs").at("INPUT_KEY", "default")
  │                                                                      ^^^^

Thanks

The second argument to at is named default (and named arguments must be named)
Additionally, you don’t need to convert sys to a dictionary, and you can directly access inputs as a property of sys:

#let input = sys.inputs.at("INPUT_KEY", default: "default")

Okay, thanks I missed that part with named argument vs positional.

I thought that the compiler could tell and explain more precisely the error

Btw for the dict of sys I just took inspiration of the documentation

Thanks!!

Indeed, sys is a module. Modules can be converted to dictionaries, as in the screenshot you’ve just shown, but fields/methods/variables defined in the module can also be referenced with dot notation (like sys.inputs).
As for the error, I agree that it is not always obvious when an argument should be named instead of positional

2 Likes