Skip to content

[bug] not keyword reserved but unusable as unary operator #3

@thwbh

Description

@thwbh

Module

core

Version

0.1.1

Environment

OS: macOS 15.5
Rust: 1.77.2

Description

not is reserved as KwNot in the lexer keyword table, which means it cannot be used as a variable name. However, it only works in two specific positions: is not and not in. Using not as a unary boolean negation (e.g., {#if not loop.last}) produces Parse error: Expected expression, got KwNot.

The keyword occupies namespace without being functional in the expected position. Users coming from Jinja2/Tera will write not x instinctively and get a confusing parse error. The fix is either:

  • Allow not as a unary operator synonym for ! in parse_unary()
  • Or remove not from the keyword list and handle it contextually inside is / in parsing only

Code Sample

Template: {#if not loop.last}, {/if}

`Error:    Parse error at 1:5: Expected expression, got KwNot`

Workaround: 

{#if !loop.last}, {/if}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions