"Inline compilation error" when executing JavaScript code in JavaScriptCore

I am executing the following javascript code on iOS using the JavaScriptCore framework. Javascript code verified.

var myCallback = undefined; *browserify logic* { 1: [function(require, module, exports) { var q = require('./user'); var p = new Promise(function(resolved, reject) { myCallback = function() { resolved('test'); } }); p.then(function(x) {printFunc('test');}).catch(function(e){printFunc('test2');}); q(); }, { "./user": 2 }], 2: [function(require, module, exports) { function q() { printFunc("Callback called!"); myCallback(); printFunc("Callback called end!"); } module.exports = q; }, {}] }, {}, [1]); 

printFunc is a method implemented in Swift that just prints something for the console. Here is the implementation:

  let printFunction : @convention(block) (String) -> String = {input in print("|\(input)|") return "" } 

The problem is that I get the following error:

 |Callback called!| Error compiling builtin: Invalid private name '@capabilities' |Callback called end!| 

Even stranger, if I delete the β€œCallback called!” Fingerprints and "Callback call end!" the code runs without errors and it prints a "test".

Have you guys encountered this strange behavior? Is this a known bug with the implementation of Promise?

+5
source share
1 answer

This is a bug in the implementation of the JavascriptCore Promise. I opened a ticket at Apple, and this is confirmed.

The workaround is to implement your own implementation of Promise.

+1
source

Source: https://habr.com/ru/post/1259122/


All Articles