# Why are some IDs and referenced declarations negative numbers in AST?

**URL:** <https://forum.soliditylang.org/t/why-are-some-ids-and-referenced-declarations-negative-numbers-in-ast/3330>\
**Category:** Language Design\
**Created:** [March 20, 2025, 4:04pm UTC](https://forum.soliditylang.org/t/why-are-some-ids-and-referenced-declarations-negative-numbers-in-ast/3330 "2025-03-20T16:04:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TilakMaddy](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/tilakmaddy/32/1563_2.png) [@TilakMaddy](https://forum.soliditylang.org/u/TilakMaddy)\
**Post date:** [March 20, 2025, 4:04pm UTC](https://forum.soliditylang.org/t/why-are-some-ids-and-referenced-declarations-negative-numbers-in-ast/3330/1 "2025-03-20T16:04:10Z")

</div>

Each solc process instantiates the parser [once, for all source files,](https://github.com/ethereum/solidity/blob/a65229279d769a7b2936aef2aa802d77abbdc343/libsolidity/interface/CompilerStack.cpp#L361C2-L371C50)  
And the node ids of the parser start with [0](https://github.com/ethereum/solidity/blob/a65229279d769a7b2936aef2aa802d77abbdc343/libsolidity/parsing/Parser.h#L255C2-L256C30)then auto [increment](https://github.com/ethereum/solidity/blob/a65229279d769a7b2936aef2aa802d77abbdc343/libsolidity/parsing/Parser.h#L218C2-L219C48) …

So it appears as though you shouldn’t have negatives

---

<div class="post-metadata">

**Author:** ![cameel](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.soliditylang.org/cameel/32/34_2.png) [@cameel](https://forum.soliditylang.org/u/cameel)\
**Post date:** [March 21, 2025, 2:14am UTC](https://forum.soliditylang.org/t/why-are-some-ids-and-referenced-declarations-negative-numbers-in-ast/3330/2 "2025-03-21T02:14:32Z")

</div>

These are assigned to definitions of global builtins, which do not have definitions in the source file and only exist internally so that the compiler can point at something. They get negative IDs to differentiate them from user’s definitions. See `GlobalContext.cpp` for a full list:

> <https://github.com/ethereum/solidity/blob/v0.8.29/libsolidity/analysis/GlobalContext.cpp#L39-L66>

You won’t ever see them in AST node’s `id` field though. Only in `referencedDeclaration` and possibly some other fields that refer to IDs of other AST nodes.
