cetz skill: correct the anchor gotcha's mechanism, and add four more - #598
Conversation
The skill said cetz 'treats anchor: specially'. It does not. The cause is the import cetz.draw: * that a drawing helper needs in its own body: it runs inside the function after the parameters are bound and shadows any parameter sharing a name with a cetz.draw export. Isolated by removing the inner import from an otherwise identical helper, which compiles. That turns a one-name warning into a rule, and covers fill and stroke as well — a parameter named fill fails with 'expected color, gradient, tiling, or none, found function' reported inside cetz's canvas.typ, nowhere near the helper. Four more, each one compile failure during the rotated-BC figure: - let h(x) shadows Typst's horizontal-spacing h(), so a figure defining a surface height breaks every #h(0.4em) in a label, with an error naming neither; - a multi-line arithmetic expression in a let ends at the first newline unless parenthesised, reported as 'unknown variable: x'; - content() anchored west centres a multi-line block vertically, so a caption that wraps grows upwards into the heading above it — nothing errors, it just overlaps; - joining nodes by a distance threshold is not a triangulation and silently omits nodes, plus the two follow-ons for a non-convex domain: Delaunay fills the convex hull so cull by centroid, and a perfect lattice gives degenerate triangles so stagger the rows. Underworld development team with AI support from Claude Code
Adversarial review — documentation, skills and tooling (#476, #580, #598, #599)Reviewed together because none of them changes library behaviour and the useful #580 —
|
All six entries cost a compile failure during the rotated-boundary-conditions figure, so they are diagnosed rather than recalled.
The existing entry had the wrong mechanism
The skill said cetz "treats
anchor:specially". It does not. The cause is theimport cetz.draw: *that a drawing helper needs in its own body — it runs inside the function after the parameters are bound, and shadows any parameter sharing a name with acetz.drawexport.Isolated: the same helper without the inner import compiles fine. That is what identifies the import rather than the parameter name.
This matters because it converts a one-name warning into a rule. A parameter named
fillfails the same way, with an error that is much harder to read:— reported inside cetz's own source, nowhere near the helper. And it gives the second fix: if the helper does not actually draw, drop the inner import instead of renaming.
Four new entries
let h(x) = ...shadows Typst'sh(). A figure defining a surface height ash(x)breaks every#h(0.4em)used for spacing in a label, failing with "cannot add length and float" — an error naming neither the function nor the label.letends at the first newline unless parenthesised, reported asunknown variable: x, which sends you looking at the wrong line.content()anchored"west"centres a multi-line block vertically, so a caption that wraps grows upwards into the heading above it. Nothing errors — it only shows up in the PNG.Documentation only — no code paths touched.
Underworld development team with AI support from Claude Code