From 3264511bdce7187de6a65729dfa8733b361fbcbf Mon Sep 17 00:00:00 2001 From: Erik Takke Date: Fri, 9 Jan 2026 11:39:08 +0100 Subject: [PATCH] spec: drop `dot` when multiplying constant with one-letter variable. --- spec/expr.typ | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/expr.typ b/spec/expr.typ index 547f2cad2..745d95d23 100644 --- a/spec/expr.typ +++ b/spec/expr.typ @@ -142,7 +142,15 @@ pp <= PREC.sub ) }, - "*": (pp, rec, e) => mwrap($#e.slice(1).map(rec.with(PREC.mul)).join($dot$)$, pp < PREC.mul), + "*": (pp, rec, e) => { + if e.len() == 3 and type(e.at(1)) == int and type(e.at(2)) == str and e.at(2).len() == 1 { + // multiplication of a constant with one-letter variable. + // Dropping the "dot" + mwrap($#e.slice(1).map(rec.with(PREC.mul)).join($$)$, pp < PREC.mul) + } else { + mwrap($#e.slice(1).map(rec.with(PREC.mul)).join($dot$)$, pp < PREC.mul) + } + }, "/": (pp, rec, e) => $#rec(PREC.div, e.at(1)) / #rec(PREC.div, e.at(2))$, "^": (pp, rec, e) => { assert(type(e.at(1)) == int and type(e.at(2)) == int, message: "Can only exponentiate constants")