Skip to content

ruleStack.clone() doesn't actually clone #228

@RedCMD

Description

@RedCMD

The clone() function on StateStack doesn't actually clone the object, but instead just returns the original object (reference)
meaning, tokenizeLine() will still modify the ruleStack that I was given

clone(): StateStack;

Problem is that the clone implementation doesn't actually do any cloning

public clone(): StateStackImpl {
return this;
}

instead something like structuredClone() should be used or use the clone function provided in the utils.ts file
export function clone<T>(something: T): T {
return doClone(something);
}

Found this out when the _enterPos and _anchorPos kept getting modified externally

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions