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
  • Going back to the receiveMagVars question, I verified that the following code (with explicit types for the makeWebRequest callback) compiles for me in SDK 4.1.4 Compiler 2 Beta:

        function receiveMagVars(response as Lang.Number, weatherObj as Null or Lang.Dictionary or Lang.String) as Void {
        }
    
        function test() as Void {
            Communications.makeWebRequest(
    			"fake/url",
    	 		null,
    			{
    				:method => Communications.HTTP_REQUEST_METHOD_GET,
    				:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
    			},
    			method(:receiveMagVars)
    		);
        }
    

Comment
  • Going back to the receiveMagVars question, I verified that the following code (with explicit types for the makeWebRequest callback) compiles for me in SDK 4.1.4 Compiler 2 Beta:

        function receiveMagVars(response as Lang.Number, weatherObj as Null or Lang.Dictionary or Lang.String) as Void {
        }
    
        function test() as Void {
            Communications.makeWebRequest(
    			"fake/url",
    	 		null,
    			{
    				:method => Communications.HTTP_REQUEST_METHOD_GET,
    				:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
    			},
    			method(:receiveMagVars)
    		);
        }
    

Children
No Data