{
"@context": "https://nxdlang.org/schema",
"doc_id": "PT204",
"title": "PT204",
"description": "Specialty Nim Tests",
"layer": "Passed Tests",
"category": "Passed Specialty Test",
"keywords": [],
"doc_version": "1.0",
"status": "active"
}
### PT204 (specialty test)
NXD Sample:
```nxd
MODULE NIM_SCOPE_LIFETIME
FUNC CREATE_VALUE()
LET VALUE SET "temporary"
PRINTLN(VALUE)
// testing scope destruction candidate. The VALUE variable is created in the CREATE_VALUE function and should be destroyed when the function scope ends. This should succeed.
FUNC MAIN()
CREATE_VALUE()
PRINTLN("complete")
```
Result:
COMPILER:
SEMANTICS:
Expected Output:
Actual Output:
```json
{
"module": {
"name": "NIM_SCOPE_LIFETIME",
"imports": []
},
"types": [],
"traits": [],
"impls": [],
"functions": [
{
"name": "CREATE_VALUE",
"params": [],
"return_type": null,
"body": [
{
"Let": {
"name": "VALUE",
"value": {
"Literal": {
"String": "temporary"
}
}
}
}
]
},
{
"name": "MAIN",
"params": [],
"return_type": null,
"body": [
{
"Expr": {
"Call": {
"func": "CREATE_VALUE",
"args": []
}
}
}
]
}
],
"statements": []
}
```
```nim
# nim_scope_lifetime
proc create_value() =
var value = "temporary"
proc main() =
create_value()
```
Notes:
Documentation