Skip to content

Confusing "missing argument" error message for function in math mode #3802

Open

Description

@user202729

Description

Currently, the following code

#let ff(x)=x
$ff(f: X → Y)$

raises "missing argument: x" instead of "unexpected argument: f".

Use Case

Because the parsing in math mode is special: (almost) everything are passed verbatim to the function as a math list.

So, once you have defined a function, you should expect that you can pass almost everything to the function without escaping:

#let ff(x)=x
$ff(α+β×γ)$

Well, almost everything. If there's a comma there will of course be a problem, but the error message is easy to understand:

$ff(α+β, γ)$

The case where there's an extraneous

Activity

  1. added
    feature request
    on Mar 26, 2024
  2. added
    scripting
    math
    on Apr 1, 2024
  3. added
    diagnostics
    and removed
    scripting
    on Jul 16, 2024
  4. added a commit that references this issue on Sep 12, 2024
    44de5c9
  5. mkorje commented on Sep 23, 2024

    @mkorje
    Collaborator

    I'd just note that this potentially confusing error message isn't only a math mode problem.

    #let ff(x)=x
    #ff(f: [X])

    The above also produces a "missing argument: x" error.

    The "unexpected argument: {name}" error message is raised on any remaining arguments, only after the required arguments have been accounted for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    diagnosticsfeature requestmath

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions