Skip to content

Support r[;] as a tensor without indices in index notation #325

Done

Description

@lkdvos

An output tensor without indices written as r[;] is not recognized by the index-notation parser, while r[] works:

julia> using TensorOperations

julia> A = randn(2, 2);

julia> @tensor r[] := A[1; 1]   # works

julia> @tensor r[;] := A[1; 1]
ERROR: syntax: unsupported assignment operator ":="

@macroexpand @tensor r[;] := A[1; 1] returns the expression unchanged, so the error only surfaces when Julia lowers the leftover :=.

r[;] parses as Expr(:typed_ncat, :r, 1) rather than :ref/:typed_vcat, so isgeneraltensor(:(r[;])) is false. Since [;] is the natural way to write "empty codomain and empty domain" when using the A[a b; c d] split notation (e.g. in TensorKit's @planar, which currently throws an AssertionError on it from a postprocessor), it would be nice if Expr(:typed_ncat, x, 1) without further arguments were treated as x[].

(TensorOperations v5.8.2)

Activity

  1. gezerui888 commented on Nov 25, 2026

    @gezerui888
    Contributor

    I’ll update the parser to accept r[;] when both index lists are empty and add regression tests for the trace.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions