Skip to content

cetz.draw.set-style causes panic when styling angle #1114

Description

@antinomie8

Consider the following example:

#import "@preview/cetz:0.5.2"
#import "@preview/cetz-plot:0.1.4"

#cetz.canvas({
	cetz.draw.set-style(
		angle: (hello: "world"),
	)
	cetz-plot.plot.plot({
		cetz-plot.plot.add(domain: (-1, 1), x => x)
	})
})

I get the following error message:

error: panicked with: "Failed to resolve coordinate system: (hello: \"world\")"
    ┌─ @preview/cetz:0.5.2/src/coordinate.typ:359:2
    │
359 │     panic("Failed to resolve coordinate system: " + repr(c))
    │     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
full stack traceback
error: panicked with: "Failed to resolve coordinate system: (hello: \"world\")"
    ┌─ @preview/cetz:0.5.2/src/coordinate.typ:359:2
    │
359 │     panic("Failed to resolve coordinate system: " + repr(c))
    │     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `_resolve-system`
    ┌─ @preview/cetz:0.5.2/src/coordinate.typ:410:10
    │
410 │     let t = _resolve-system(c)
    │             ^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `resolve`
     ┌─ @preview/cetz:0.5.2/src/draw/shapes.typ:1138:19
     │
1138 │       let (_, c) = coordinate.resolve(ctx, angle)
     │                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this function call
   ┌─ @preview/cetz:0.5.2/src/process.typ:19:22
   │
19 │   (ctx, ..element,) = element-func(ctx)
   │                       ^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `element`
    ┌─ @preview/cetz:0.5.2/src/process.typ:100:12
    │
100 │     let r = element(ctx, el, compute-bounds: compute-bounds)
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `many`
    ┌─ @preview/cetz:0.5.2/src/draw/grouping.typ:560:38
    │
560 │     let (ctx, drawables, bounds: _) = process.many(ctx, util.resolve-body(ctx, body), compute-bounds: false)
    │                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this function call
   ┌─ @preview/cetz:0.5.2/src/process.typ:19:22
   │
19 │   (ctx, ..element,) = element-func(ctx)
   │                       ^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `element`
    ┌─ @preview/cetz:0.5.2/src/process.typ:100:12
    │
100 │     let r = element(ctx, el, compute-bounds: compute-bounds)
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `many`
    ┌─ @preview/cetz:0.5.2/src/draw/grouping.typ:276:42
    │
276 │     (ctx: group-ctx, drawables, bounds) = process.many(group-ctx, util.resolve-body(group-ctx, body), compute-bounds: wants-bou
nds)
    │                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^

help: error occurred in this function call
   ┌─ @preview/cetz:0.5.2/src/process.typ:19:22
   │
19 │   (ctx, ..element,) = element-func(ctx)
   │                       ^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `element`
    ┌─ @preview/cetz:0.5.2/src/process.typ:100:12
    │
100 │     let r = element(ctx, el, compute-bounds: compute-bounds)
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `many`
    ┌─ @preview/cetz:0.5.2/src/draw/grouping.typ:276:42
    │
276 │     (ctx: group-ctx, drawables, bounds) = process.many(group-ctx, util.resolve-body(group-ctx, body), compute-bounds: wants-bou
nds)
    │                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^

help: error occurred in this function call
   ┌─ @preview/cetz:0.5.2/src/process.typ:19:22
   │
19 │   (ctx, ..element,) = element-func(ctx)
   │                       ^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `element`
    ┌─ @preview/cetz:0.5.2/src/process.typ:100:12
    │
100 │     let r = element(ctx, el, compute-bounds: compute-bounds)
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `many`
    ┌─ @preview/cetz:0.5.2/src/draw/grouping.typ:276:42
    │
276 │     (ctx: group-ctx, drawables, bounds) = process.many(group-ctx, util.resolve-body(group-ctx, body), compute-bounds: wants-bou
nds)
    │                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^

help: error occurred in this function call
   ┌─ @preview/cetz:0.5.2/src/process.typ:19:22
   │
19 │   (ctx, ..element,) = element-func(ctx)
   │                       ^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `element`
    ┌─ @preview/cetz:0.5.2/src/process.typ:100:12
    │
100 │     let r = element(ctx, el, compute-bounds: compute-bounds)
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `many`
    ┌─ @preview/cetz:0.5.2/src/draw/grouping.typ:276:42
    │
276 │     (ctx: group-ctx, drawables, bounds) = process.many(group-ctx, util.resolve-body(group-ctx, body), compute-bounds: wants-bou
nds)
    │                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^

help: error occurred in this function call
   ┌─ @preview/cetz:0.5.2/src/process.typ:19:22
   │
19 │   (ctx, ..element,) = element-func(ctx)
   │                       ^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `element`
    ┌─ @preview/cetz:0.5.2/src/process.typ:100:12
    │
100 │     let r = element(ctx, el, compute-bounds: compute-bounds)
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `many`
   ┌─ @preview/cetz:0.5.2/src/canvas.typ:82:33
   │
82 │   let (ctx, bounds, drawables) = process.many(ctx, body)
   │                                  ^^^^^^^^^^^^^^^^^^^^^^^

The panic also happens if I replace (hello: "world) with an empty dict (:) or a dict containing valid style values like stroke, radius, etc.
On the other hand, other keys (like stroke, content or axis) cause no issue.

Is this supposed to be ?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions