https://developer.garmin.com/connect-iq/monkey-c/monkey-types says that
An interface type requires a class to contain a set of member declarations. The members can be member variables and functions.
It goes on to give examples with member variables, but none with functions.
I tried:
function foobar(
x as interface {
function toString() as String;
}
) as String {
return x.toString();
}
and the compiler crashes:
Executing task: java -Xms1g -Dfile.encoding=UTF-8 -Dapple.awt.UIElement=true -jar .../connectiq-sdk-mac-4.1.7-2022-11-21-562b8a195/bin/monkeybrains.jar -o bin/program.prg -f .../monkey.jungle -y .../developer_key -d device -w -l 3
ERROR: null
I get the same thing if I try x.toNumber(). I tried changing it to "fizzle" (a name that doesn't exist anywhere in my project), and got:
ERROR: device: .../bug.mc:5 Undefined symbol ':fizzle' detected.
Note that the error occurs on the line that tries to call x.fizzle().
Then I added a class that does have a fizzle method to my project:
class Fizzle { function fizzle() as String { return "Hello"; } }
And now I'm back to "ERROR: null".
The above is all with 4.1.7. I get the same results with "4.2.0 beta 2". With 4.1.5 I get similar results, but in addition to "ERROR: null" I get a Java null pointer exception and backtrace.