Skip to content

Scope definitions should not depend on JSON member order #401

Open

Description

@djolertrk

The scope schema says definitions are evaluated in order, allowing later variables to reference earlier ones. But JSON objects are unordered.

For example:

{
  "define": {
    "start": 0,
    "end": {"~sum": ["start", 32]}
  },
  "in": {
    "location": "memory",
    "offset": "start",
    "length": "end"
  }
}

Sorting the keys puts end before start, breaking the dependency under the current wording.

In solc, we work around this by emitting a separate nested define/in scope for each binding.

Could the spec use an explicitly ordered representation, or define evaluation without relying on object member order?

Raised during solc review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions