Ticket Created
over 2 years ago

CIQQA-1381

Compiler 4.1.4 Beta - makeWebRequest

I'm getting a confusing error:

ERROR: fenix7: /Users/alansmith/Documents/watchApp/raceQs/source-bigMem/speedHeadingBIG.mc:890,8: Invalid '$.Toybox.Lang.Method(response as Any, weatherObj as Any) as Any' passed as parameter 4 of type 'PolyType<(callback(responseCode as $.Toybox.Lang.Number, data as Null or $.Toybox.Lang.Dictionary or $.Toybox.Lang.String) as Void) or (callback(responseCode as $.Toybox.Lang.Number, data as Null or $.Toybox.Lang.Dictionary or $.Toybox.Lang.String, context as $.Toybox.Lang.Object) as Void)>'.

on:

Comm.makeWebRequest(
			url,
	 		null,
			{   :headers => headers,
				:method => Comm.HTTP_REQUEST_METHOD_GET,
				:responseType => Comm.HTTP_RESPONSE_CONTENT_TYPE_JSON
			},
			method(:receiveMagVars)
		) ;

Which runs fine with 4.1.3.

4.1.4 Beta has thrown up a whole bunch (90-odd!) of errors which I'm working through. Some are interesting, but I'm disappointed that it refuses to accept Numbers as Identifier in Menu.addItem. That a symbol is required seems to be a crazy fault in the language specification that has not until now been required. Prior compilers have not had a problem and this code

s_menu_layer.addItem(loadedMarks[i][$.name], i );

has worked fine, and I assumed that it was a documentation error.

Parents
  • "Some are interesting, but I'm disappointed that it refuses to accept Numbers as Identifier in Menu.addItem. That a symbol is required seems to be a crazy fault in the language specification that has not until now been required. Prior compilers have not had a problem"

    I went back to an old SDK (3.1.8) and the docs always specified that the 2nd parameter to Menu.addItem should be a symbol. If passing a number worked before, seems to me that's out-of-spec behavior and shouldn't be relied upon.

    Having said that, if it really bothers you, I think you can use as to cast the number to a symbol. e.g.

        function baz(x as Lang.Symbol) {
            System.println("x instanceof Lang.Symbol = " + ((x instanceof Lang.Symbol) ? "true" : "false")); // prints "false" when 5 is passed, naturally
        }

        function bar() {
            baz(5 as Lang.Symbol); //compiles
            baz(5); //produces compile error
        }
Comment
  • "Some are interesting, but I'm disappointed that it refuses to accept Numbers as Identifier in Menu.addItem. That a symbol is required seems to be a crazy fault in the language specification that has not until now been required. Prior compilers have not had a problem"

    I went back to an old SDK (3.1.8) and the docs always specified that the 2nd parameter to Menu.addItem should be a symbol. If passing a number worked before, seems to me that's out-of-spec behavior and shouldn't be relied upon.

    Having said that, if it really bothers you, I think you can use as to cast the number to a symbol. e.g.

        function baz(x as Lang.Symbol) {
            System.println("x instanceof Lang.Symbol = " + ((x instanceof Lang.Symbol) ? "true" : "false")); // prints "false" when 5 is passed, naturally
        }

        function bar() {
            baz(5 as Lang.Symbol); //compiles
            baz(5); //produces compile error
        }
Children
No Data