Need help with Generics / trans compiler

Monkey Forums/Monkey Programming/Need help with Generics / trans compiler

Nobuyuki(Posted 2013) [#1]
Hello,

Please consider this thread a prelude of things to come. I'm attempting to port some code over to the world of Monkey, and I'm having problems with trans compiling it. At its core, it takes an array of T, and a Comparator<T> class as constructor arguments. The main functions are publicly exposed, but everything else shouldn't really be -- I've made the ctor public due to my lack of understanding at the cryptic error I'm getting at compile time.

The bulk of the code (as of this posting) is listed in the following file: https://github.com/nobuyukinyuu/monkey-timsort/blob/master/timsort.monkey (the repo includes diddy's Arrays<T> functions and Comparator<T> as well)

The error I'm getting when attempting to compile results when either trying to construct a TimSort<T> object, or call on its static function, Sort, which can take the same arguments the ctor takes. The specific error usually lists the line where instantiation or function call is attempted, with "Internal error". The trace ends at that line and doesn't attempt to show me any errors in the TimSort<T> class.

Example output when attempting to compile the above code:
TRANS monkey compiler V1.46
Parsing...
Semanting...
E:/Projects/Monkey/Code/monkey-timsort/TimSortTest.monkey<23> : Internal error
Monkey Runtime Error : E:/Projects/Monkey/Code/monkey-timsort/TimSortTest.monkey<23> : Internal error


I'm running off the assumption that this may be a problem with Generics, since no more specific error seems to be forthcoming, but I am uncertain. Reference code exists in timsort.monkey's header in the form of a java and a js file. Can any Monkey gurus help me out on this one?


Some notes:

1. Comparator is an Interface in Java, but Interfaces can't be Generic in Monkey, so it's implemented as a class here.
2. static methods were implemented in Monkey as Functions. All other methods were implemented under the original code's scoping using monkey's Public/Private directives.
3. static <T> voids were implemented as Function:Voids, since in the class scope, "T" is already presumed to be the generic type in Monkey
4. Monkey doesn't utilize wildcard types; this limits the scope of the implementation compared to the code it borrows from but shouldn't interfere with its operation when sticking to a single type like in the example.

I know this could be a real tough nut, and chances are I might not get any replies to it, but any help to set me in the right direction would be greatly appreciated.


muddy_shoes(Posted 2013) [#2]
You should report this as a bug. The Monkey build pipeline shouldn't spit out unspecified errors. "Internal Error" means that something unexpected occurred in the build code itself. There may well be a change you can make to your code that would avoid the issue but it's still a bug with Monkey itself.

The default "Internal Error" text should be changed to "Internal Error, report this problem to BRL".


Nobuyuki(Posted 2013) [#3]
I'm not sure how to properly file this as a bug, since the codebase I have to reproduce it is "large" and I'm not sure where to localize the problem. Do you have BRL's ear, by any chance? I can report it as-is in the bug reports forum, but I don't want to be rude since there are enough "bugs" reported in there that ended up not being bugs at all. I'll do it if that's what the proper thing to do is, though!


muddy_shoes(Posted 2013) [#4]
Just make sure it is reproducible by building timsorttest.monkey and point Mark at the repo. There's nothing rude about reporting a build error that is undecipherable.


Nobuyuki(Posted 2013) [#5]
yep, it's reproducible under v69 on my system. I've posted a thread on the bug forum, feel free to confirm the results there.