Skip to content

Parser fails to handle multi-dot namespaces (Systemic Issue across init python in, define, default, transform) #539

@juperMonkey

Description

@juperMonkey

Extension version

805.1.0

Issue description

The extension's parser appears to fundamentally mishandle identifiers that contain dots (nested namespaces). While simple dotted names (e.g., my_store.var) sometimes work, complex or nested dotted names cause failures.

It appears the parser assumes identifiers are strictly alphanumeric (\w+) or hardcodes support for only a single dot in specific places. This breaks support for Ren'Py project structures that use nested named stores.

I have verified failures in the following constructs:

  1. init python in: Statement

    • init python in my.store: → Fails (Context leak/Shadowing)
    • init python in my.sub.store: → Fails
  2. define / default Statements

    • define my_store.var = 1 → Works (likely unintentional/partial match)
    • define my_store.sub.var = 1 → Fails (Parser cannot handle 2+ dots)
  3. Transform Statement:

    • transform my_store.trans(): → Fails (Not recognized even with a single dot)

Steps to reproduce:

init python in main_store:
    def func(): ...
    class MyClass:
        def method(): ...

init python in main_store.substore:
    def func(): ...
    class MyClass:
        def method(): ...

define variable = 1
define my_store.variable = 1
define my_store.substore.variable = 1

transform my_transform():
    pass

transform my_store.my_transform():
    pass

label test:
    # --- Function Tests ---
    $ main_store.func() # ✅ Works
    $ main_store.substore.func() # ❌ Definition not found (Extension doesn't see the dotted namespace)

    # --- Class Tests ---
    $ main_store.MyClass # ❌ Definition not found (Likely overwritten/corrupted index)
    $ main_store.substore.MyClass # ❌ Definition not found

    # --- Method Tests ---
    $ main_store.MyClass.method() # ❌ Fails (jumps to main_store.substore.MyClass.method)
    # The second class shadowed the first one in the index.

    $ main_store.substore.MyClass.method() # ✅ Works (Oddly, the method is indexed even if the class lookup fails)

    # --- Definition Tests ---
    $ variable # ✅ Definition found
    $ my_store.variable # ✅ Definition found
    $ my_store.substore.variable # ❌ Definition not found
    # NOTE: define and default, both have same results

    # --- Transform Tests ---
    $ my_transform() # ✅ Definition found
    $ my_store.my_transform() # ❌ Definition not found

Impact:

  • Shadowing/Context Leaks: Classes in nested stores overwrite classes in parent stores.
  • Broken Navigation: "Go to Definition" fails for symbols with 2+ dots.
  • No argument suggestions or auto-complete for functions in nested stores.

Possible Cause:

It appears that the extension's tokenizer or regex patterns stop reading identifiers when they encounter a dot (or a second dot). Updating the parser logic to treat the dot character (.) as a valid part of a namespace identifier—for both scope detection and symbol indexing—would likely resolve these issues (\w+ to [\w.]+).

Scope inspector screenshots

Code

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions