{
"@context": "https://nxdlang.org/schema",
"doc_id": "PT205",
"title": "PT205",
"description": "Specialty Nim Tests",
"layer": "Failed Tests",
"category": "Failed Specialty Test",
"keywords": [],
"doc_version": "1.0",
"status": "active"
}
### PT205 (specialty test)
NXD Sample:
```nxd
MODULE NIM_COMPTIME_CONSTANT
FUNC MAIN()
CONST RESULT SET 40 ADD 2
PRINTLN(RESULT)
// TESTING COMPILE TIME CONSTANTS. RESULT IS COMPUTED AT COMPILE TIME AND THEN PRINTLN IS CALLED ON RESULT. THIS SHOULD SUCCEED.
```
Result:
COMPILER:
SEMANTICS:
Expected Output:
Actual Output:
```json
{
"module": {
"name": "NIM_COMPTIME_CONSTANT",
"imports": []
},
"types": [],
"traits": [],
"impls": [],
"functions": [
{
"name": "MAIN",
"params": [],
"return_type": null,
"body": [
{
"Const": {
"name": "RESULT",
"value": {
"Binary": {
"kind": "ADD",
"left": {
"Literal": {
"Int": 40
}
},
"right": {
"Literal": {
"Int": 2
}
}
}
}
}
},
{
"Expr": {
"Call": {
"func": "PRINTLN",
"args": [
{
"Var": "RESULT"
}
]
}
}
}
]
}
],
"statements": []
}
```
```nim
# nim_comptime_constant
proc main() =
let result = 40 + 2
println(result)
```
Notes:
Documentation