mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2942] [Issue]: {{#if}} number comparisons (> < >= <=) silently don't work and always pass #1520
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1520
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2942
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
{{#if}}only understands==,!=,=,is,is not,contains,includes. Number comparisons like>,<,>=,<=are not supported — but instead of erroring, the condition silently falls back to "is this non-empty?", which is almost always true. So a condition the author expects to be false (e.g.{{#if 3 > 5}}) quietly passes and the wrong text is shown.Also note
==compares as lowercased strings, not numbers, so{{#if 5 == 5.0}}is false.How to reproduce (try it yourself)
Put this in a character field, lorebook entry, or preset:
You'll see:
THIS SHOULD NOT SHOWappears in the prompt.Expected: nothing (1 is not greater than 100).
Where it is
packages/shared/src/utils/macro-engine.ts—parseConditionExpression(line 512) lists the supported operators;><>=<=aren't in it, so the whole expression becomes the "truthy" case inevaluateCondition(line 553).compareConditionValues(531) only does string equality/contains, never numeric comparison.What's happening
The operator regex doesn't include the comparison operators, so
3 > 5isn't parsed as a comparison at all — it's treated as a single value and checked for non-emptiness, which passes.Suggested fix
Either add real numeric comparison support (
><>=<=, comparing as numbers when both sides are numeric), or — if comparisons are intentionally unsupported — make an unrecognized operator evaluate to false (or leave the block unrendered) rather than silently truthy, so authors notice. Document which operators are supported.Found by a code review of v2.0.6; please verify the reproduction before fixing.
@SpicyMarinara commented on GitHub (Jun 28, 2026):
Addressed in the staging fixes: {{#if}} now recognizes >, <, >=, and <= operators and compares numerically when both sides are numbers, including numeric equality such as 5 == 5.0. Regression coverage was added for false and true numeric branches.