Skip to content

{.global.} and const interact weirdly #11285

Open
@davidgarland

Description

@davidgarland

The current behavior for const and {.global.} is somewhat confusing; I'm not sure if this is intended behavior or not.

Example

proc unique: int =
  var id {.global.} = 0
  result = id
  id += 1

const x = unique()
const y = unique()

let z = unique()
let w = unique()

echo x
echo y
echo z
echo w

Current Output

0
0
0
1

Expected Output

Either

0
1
0
1

or

0
1
2
3

depending upon what is deemed "correct."

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