Skip to content

[Bug]: Colliding state keys are not detected #335

@joe-p

Description

@joe-p

Description

I have a contract where I accidentally defined two global state values with the same key via inheritance. The compiler let this compile which lead to unexpected bugs in contract behavior.

Steps to Reproduce

Compile contracts with the following state

export class MimcMerkle extends Contract {
  rootCounter = GlobalState<uint64>({ key: "c" });
export class Mithras extends MimcMerkle {
  creationRound = GlobalState<uint64>({ key: "c" });

Expected Behavior

The compiler throws an error when keys collide. In TEALScript there was a check for colliding keys but also a check for potential collision between keys, prefixes, and dynamic types. We don't need all of that to fix this specific issue, but it may be nice to have in the future.

https://github.com/algorandfoundation/tealscript/blob/dev/src/lib/compiler.ts#L5648

Screenshots

No response

Device Info

    version: 1.1.0(tslib@2.8.1)

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions