bmx-ng / bcc

A next-generation bcc parser for BlitzMax
zlib License
33 stars 13 forks source link

[Generics] Unused nested generics unable to compile #617

Open thareh opened 1 year ago

thareh commented 1 year ago

Good day,

Using the following code will cause a lot of compilation errors.

test.mod/generics.mod/generics.bmx

SuperStrict

Module Test.Generics

Framework BRL.Blitz
Import BRL.Collections

Type TTempMap<K, V>

    Field map:TTreeMap<K, V> = New TTreeMap<K, V>()

EndType

example.bmx

SuperStrict

Framework BRL.Blitz
Import BRL.StandardIO
Import Test.Generics

Local map:TTempMap<String, String> = New TTempMap<String, String>()

'If map.map
'   Print 1
'EndIf

Print "DONE"

If you uncomment the if-block it works.

Thanks!

GWRon commented 7 months ago

With latest bcc the modules can no longer use framework.

you need to use:

SuperStrict
Module Test.Generics

Import BRL.Blitz
Import BRL.Collections

Type TTempMap<K, V>

    Field map:TTreeMap<K, V> = New TTreeMap<K, V>()

EndType

It blamed an incorrect module line at the first try but then in the second processed a bit more until it errored out:

Building untitled2
[ 14%] Processing:generics.bmx
[ 88%] Compiling:generics.bmx.release.linux.x64.c
[ 91%] Compiling:untitled2.bmx.console.release.linux.x64.c
In file included from /home/ronny/Arbeit/Tools/BlitzMaxNG/tmp/.bmx/untitled2.bmx.console.release.linux.x64.c:1:
/home/ronny/Arbeit/Tools/BlitzMaxNG/tmp/.bmx/untitled2.bmx.console.release.linux.x64.h:637:20: error: conflicting types for ‘bbbrl_blitz_IIterator_Current_m’; have ‘BBString * (*)(struct bbbrl_blitz_IIterator_obj *)’
  637 | typedef BBSTRING (*bbbrl_blitz_IIterator_Current_m)(struct bbbrl_blitz_IIterator_obj*);
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ronny/Arbeit/Tools/BlitzMaxNG/tmp/.bmx/untitled2.bmx.console.release.linux.x64.h:340:47: note: previous declaration of ‘bbbrl_blitz_IIterator_Current_m’ with type ‘bbbrl_blitz_IIterator_Current_m’ {aka ‘struct _m_untitled2_TMapNodeSS_obj * (*)(struct bbbrl_blitz_IIterator_obj *)’}
  340 | typedef struct _m_untitled2_TMapNodeSS_obj* (*bbbrl_blitz_IIterator_Current_m)(struct bbbrl_blitz_IIterator_obj*);
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ronny/Arbeit/Tools/BlitzMaxNG/tmp/.bmx/untitled2.bmx.console.release.linux.x64.h:638:10: error: conflicting types for ‘_bbbrl_blitz_IIterator_Current’; have ‘BBString *(struct bbbrl_blitz_IIterator_obj *)’
  638 | BBSTRING _bbbrl_blitz_IIterator_Current(struct bbbrl_blitz_IIterator_obj*);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ronny/Arbeit/Tools/BlitzMaxNG/tmp/.bmx/untitled2.bmx.console.release.linux.x64.h:341:37: note: previous declaration of ‘_bbbrl_blitz_IIterator_Current’ with type ‘struct _m_untitled2_TMapNodeSS_obj *(struct bbbrl_blitz_IIterator_obj *)’
  341 | struct _m_untitled2_TMapNodeSS_obj* _bbbrl_blitz_IIterator_Current(struct bbbrl_blitz_IIterator_obj*);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

...