Skip to content

Problems with non-functions sharing the function call syntax in math mode #7274

Closed

Description

@isuffix

I'm adding this because it isn't tracked elsewhere, although most of the cases are present in the test suite.

In math mode the function call syntax needs to 'unparse' a call at runtime if the function identifier isn't actually a Typst function. E.g. $pi(x,y)$ will render like $pi\(x\,y\)$.

However, unparsing is currently broken/incomplete when using any special syntax for arguments, i.e. named arguments, argument spreading, and 2D arguments. We currently give poor/nonsense errors for these cases because we try to evaluate the arguments before realizing we need to unparse. E.g. $pi(x:y)$ gives "Error: unexpected argument: x" (this is distinct from #3802 because pi isn't a function).

Instead, we should either correctly unparse the special syntax, or give better error messages if we do recognize it being used with a non-function.

Also, when parsing a non-function identifier we have different behavior for delimiters: unclosed parentheses cause an error ( $pi(x$ is an error, but not $pi (x$ ) and parentheses don't pair with non-parentheses ($pi(2,5]$).

Activity

  1. added
    bug
    math
    syntax
    on Oct 31, 2025
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

    bugmathsyntax

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions