pragmagic/godot-nim

godot-nim compilation breaks on nim 979148e86

geekrelief opened this issue · 8 comments

There's a circular dependency between arrays.nim and poolarrays.nim that no longer compiles properly on nim commit 979148e86 on devel.
It's not a circular dependency. nim commit 979148e86 on devel broke the {.pure.} pragma. So Array defined in the VariantType enum isn't hidden properly so poolarrays.nim can't see arrays.nim's Array definition.

Here's the error:

godot\core\poolarrays.nim(127, 16) template/generic instantiation of `definePoolArray` from here
godot\core\poolarrays.nim(49, 26) Error: type expected, but got symbol 'Array' of kind 'enumField'

in poolarrays.nim

import arrays

definePoolArray(PoolByteArray, GodotPoolByteArray, uint8,
                godotPoolByteArray, newPoolByteArray,
                initGodotPoolByteArray)

I submitted a bug report to nim: nim-lang/Nim#16462

The latest working commit is: 3b963a81

I found out the issue is due to {.pure.} pragma https://nim-lang.org/docs/manual.html#pragmas-pure-pragma not working correctly to hide VariantType.Array

VariantType* {.size: sizeof(cint), pure.} = enum

When Array is used in the definePoolArray template:

template definePoolArray(T, GodotT, DataT, fieldName, newProcName, initProcName;
noData = false) =
proc newProcName*(arr: Array): T {.inline.} =

Will close the issue once this the nim devs resolve it.

A workaround is to prefix the VariantType enum entries like vtNil, vtArray, etc.

I get this error again with nim 1.5.1 and godot 3.3.3

Applying the same changes as in this PR fixes the issue, but for some reason this PR must have been undone at some point

yea, this no longer works.

@RecruitMain707 and @cmyka1b2c3d4 make sure you check the stub.nimble file in your project, I was having this issue and it was caused by that file forcing an old version of godot-nim, simply changing the line to requires "godot >= 0.8.0" fixed it.