Can't compile import @testable etc

Just tried Fire 10, and almost none of our code that was working fine with Fire 9.3.103.2211 compiles.

Just some of the errors:

Attributes not allowed here:

#if !ANDROID
@testable import <PACKAGE> 
#endif

Seems Fire 10 is ignoring the #if - have tried various directives with no luck. We have similar errors such as “Syntax error” trying to compile:
#if IOS
infix operator =>: Subscribe
#endif
Obviously it would be nice if Fire supported this syntax, but it’s critical it will allow us to compile code that uses inside an #if that shouldn’t apply to Fire compilation.

Variable is read-only

class Bar {
    public func foo() {
        let callback = {
            (param: String?) -> () in
            guard let _ = param else { return }
        }
    }
}

For “guard” line. Doesn’t happen if foo() is free-standing global function. We have variants of this pattern heavily throughout our code.

T has no default property

In package “A”:

 extension Array {
     public func flatMap<ElementOfResult>(_ transform: (T) -> ElementOfResult) -> [ElementOfResult] {
         return [ElementOfResult]()
     }
 }

In package “B”:

 let array = [Dictionary<String, AnyObject>]()
 let bar = array.flatMap({ $0["foo"] as? String })

Doesn’t happen if “flatMap” is defined in package B.

Will continue investigating.
Also Fire was using 150% of my CPU and weird spurious inline warnings/errors started appearing in the IDE code view (including “internal error - NullPointerException” or something similar)

Lots of UI issues too where it freezes up while editing code (then sometimes shows stack trace in a tooltip, which appears to also be in a crash log), shows “Build cancelled by user” messages every time I build, and the menus appear to include hidden “internal commands” I wouldn’t expect to see.

   class Foo
   {
        func bar() {
            let _ = {
                () -> () in
                _ = String()
            }
        }
    }

Causes a Type mismatch error on the 5th line, again doesn’t happen if bar() is freestanding.

public class NoParams
{
    public static let instance = NoParams()
}

Gives “no matching overload”.

let array = ["1", nil, "2", nil, "3", ["4", nil, "5", ["6", nil, "7", nil, "8"]]]

“cannot assign null to non-nullable”

Then at the end of the build log:

E: Internal error: System.NullReferenceException: Object reference not set to an instance of an object
  at RemObjects.Oxygene.Code.Compiler.Compiler.ResolveMembers () [0x002ab] in <6ec7cb1d1a8c419bb361a812d61b188a>:0 
  at RemObjects.Oxygene.Code.Compiler.Compiler.Compile () [0x0006a] in <6ec7cb1d1a8c419bb361a812d61b188a>:0 

Not too promising an experience so far :frowning:

Would also like to know what known issues the Silver compiler with Fire 10 is supposed to address/resolve, and in particular which known features of Swift 4.1/4.2 are being worked on, there’s quite a few we’d like to explore (e.g. is “Codable” likely to be supported?)

Thanks, logged as bugs://80478

yeah that should work. I fixed this particular case. If you see any others like it let me know and I’ll fix them.

Fixed.

Fixed.

Ah yes. Fixed.

That leaves the let array= and flatMap issue (I’ll solve those later today or tomorrow in a bit).

I wasn’t able to reproduce that one. Do you have a project that shows this? (you can send it here or privately to mailto:ck@remobjects.com if you want, I’ll delete it when I’m done).

I understand. If you want I can hand you an updated build once the other two are fixed.

Codable is on our list yes. Any specific other ones you’re curious about? Some are solved, most that aren’t are logged but we can prioritize things depending on demand.

That was only a sample of the errors I got. Most were related to code that wasn’t intended to be compiled by Silver and inside #if !ANDROID. It’s all syntactically valid Swift (as it’s compiled by Xcode), but uses types or programming language features that Silver doesn’t support.

We do have a few other issues that we were hoping might be resolved with Fire 10 relating to Enums especially, but I didn’t even get around to exploring new Swift 4.x features - it took me long enough to find minimally reproducible samples of code to produce the errors I included here.

But impressive work fixing them that quickly…how soon till the next release?

For customers we do a build every Friday. Not sure if you’re using the free one or paid. But I can upload a new build if needed

I’ve been arguing for us to sign up as a paid customer for a while…will see what the boss says when I’m back from hols in a couple of weeks :slight_smile:

1 Like

One thing that would be really curious to me is the Object reference not set to an instance of an object error. That probably triggers other ide issues too.

Oke so there seem to be two issues here:

  • by default classes (And extensions) are internal typed. So if you define them in 1 module they won’t show unless they’re public (explains 1 error): (E44) No member “flatMap” on type “Swift.Array<Dictionary<String,AnyObject>!>!” application1;

Once I fix this it gives a consistent error:

removing Java.Util (which causes java.util.Dictionary to be in scope in front of the Swift dictionary) fixes that.

And If I change the as? to as! it compiles now (because ElementOfResult is a not nullable type).

bugs://80478 got closed with status fixed.

Dylan,

I have uploaded a new build with Carlo’s fixes for you to https://secure.remobjects.com/portal/downloads/personal. This is just a. new compiler, not a new version of Fire, please refer to this docs topic on how to install the external compiler and use it with Fire.

Please let us know how this build works for you, and what, if any, issues remain.

thanx!
marc

I just tried the latest Fire 10 version (not the external compiler you uploaded for me).
Now getting:

E:Recursion in inheritance tree

#if !ANDROID
class Foo : XCTestCase {
}
#endif
extension Foo { // < --- here 
}

(Note that the error only happens if either Foo is not defined, or defined in another module)

E:Type “T” has no default property to use for array accessors
let bar = entry.flatMap({ $0["foo"] as? String }) (as per original post, though now I also get a (different) error if I move the definition of flatMap into the same module, regarding wrapped nullable types)

E:Cannot assign null to non-nulllable

import myLibrary // defines UUID
class Foo {
    var uuid: UUID?
}
class Bar {
    func test(foo: Foo?) {
        if (foo?.uuid == nil) {

        }
    }
}

Doesn’t happen if UUID defined in current module, or test occurs outside a class.

Then I still get:
E: Internal error: System.NullReferenceException: Object reference not set to an instance of an object
at RemObjects.Oxygene.Code.Compiler.Compiler.ResolveMembers () [0x002ab] in <9af3c160812c447ab9e7d980325109ba>:0
at RemObjects.Oxygene.Code.Compiler.Compiler.Compile () [0x0006a] in <9af3c160812c447ab9e7d980325109ba>:0

At end of build for that module.

E:Syntax error

#if IOS
infix operator =>: Subscribe
#endif

I don’t need this to be able to compile in Fire. It may be possible to move to a separate file, but a pain.

Likewise (code inside #if IOS)
E:Closing block expected
[weak m] in

can we get a complete testcase? thanx!

Not sure what you mean, I included minimally complete examples for all of the errors except the NullReference one. I can try creating a new project.

BTW: I just tried the “New Solution” command in Mac Fire, and it does nothing…

It may be some of the errors are because the “core” library that the 2nd library depends on is not actually building at the moment, almost entirely because Fire is not accepting the syntax for code inside #if iOS blocks. Once I remove all those however I still get:

E: Internal error: System.NullReferenceException: Object reference not set to an instance of an object at RemObjects.Oxygene.Code.Compiler.Compiler.ResolveMembers () [0x002ab] in <9af3c160812c447ab9e7d980325109ba>:0 at RemObjects.Oxygene.Code.Compiler.Compiler.Compile () [0x0006a] in <9af3c160812c447ab9e7d980325109ba>:0

This core library contains a lot of code, and isn’t something I can really provide.

But there are also definitely very weird bugs in the Fire code editor - while typing code I got some very strange behaviour, Finder windows would pop-up, strange errors with C# stack traces would appear in tool-tips etc.

I’ve managed to get a different error in a completely independent project/swift file, with this code:

public typealias Runnable = () -> ()

public func runnableWithNoExceptions(_ task: @escaping Runnable) -> Runnable {
    let ret: Runnable = {
        runWithNoExceptions(task)
    }
    return ret
}

public func runWithNoExceptions(_ task: () throws -> ()) {
    do {
        try task()
    }
    catch { // ignore compiler warning - how? 
    }
}

E: Parameter 1 is “Runnable”, should be “com.remobjects.elements.system.Action”, in call to func MyLibrary.runWithNoExceptions(_ task: com.remobjects.elements.system.Action) [/Users/dylan.nicholson/Documents/MyLibrary/Class1.swift (11)]
/Users/dylan.nicholson/Documents/MyLibrary/Class1.swift(11,23): duplicate-error E486: Parameter 1 is “Runnable”, should be “com.remobjects.elements.system.Action”, in call to func MyLibrary.runWithNoExceptions(_ task: com.remobjects.elements.system.Action)

What build are you on? IIRC this was fixed a few weeks ago…

We’ll need a concrete project that shows this — a code snippet referring to stuff that’s “off screen” is not enough. like, what is UUID — I cannot guess?

That happens when there’s a critical failure in CC, it will generate a bug report and show it in Finder. Can you email me the zip, png and txt files it generated?

10.0.0.2305 (develop)
MyLibrary.bugreport.zip (1.7 KB)

Actually yeah I have a whole lot of these files (or similar)…do you want them all?

UUID is actually just:

public __mapped class UUID => java.util.UUID {
    public init() {
        return java.util.UUID.randomUUID()
    }
    public init(uuidString: String) {
        return java.util.UUID.fromString(uuidString)
    }
    public var uuidString: String { return __mapped.toString() }
}

(actually there’s a bit more to it, but that’s the guts of it)

I get these errors with the project you sent:

import java.util
public __mapped class UUID => java.util.UUID {

}

/// A closure which can be run on q WorkQueue
public typealias Runnable = () -> ()

/// Wraps a task and logs unexpected exceptions, so they can't crash the app
/// This is particularly important over in Java land, which has the whole RuntimeException thing ready to blow chunks
public func runnableWithNoExceptions(_ task: @escaping Runnable) -> Runnable
{
	let ret: () -> () =
	{
		runWithNoExceptions(task) // E486 Parameter 1 is "Runnable", should be "com.remobjects.elements.system.Action", in call to func MyLibrary.runWithNoExceptions(_ task: com.remobjects.elements.system.Action)
	}
	return ret // E62 Type mismatch, cannot assign "com.remobjects.elements.system.Action" to "Runnable"
}

/// Run the task and swallow and log any exceptions
public func runWithNoExceptions(_ task: () throws -> ())
{
	do {
		try task()
	}
	catch // ignore compiler warning - how? { // E1 opening bracket expected, got closing bracket
											  // E0 Internal error: System.NullReferenceException: Object reference not set to an instance of an object
  at RemObjects.Oxygene.Code.TryStatementTransform.ResolvePattern (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.TryStatement tryStatement, RemObjects.Oxygene.Code.ExceptStatementElementBuilder& el1) [0x0010e] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.TryStatementTransform.ResolveStatement (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.TryStatement tryStatement) [0x00253] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitStatement (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Statement element) [0x00328] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.BeginStatementTransform.ResolveStatement (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.BeginStatement beginStatement) [0x00202] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.Compiler.NewResolveExpressionAndStatement.VisitStatement (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.Statement element) [0x003fa] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.Compiler.Compiler.ResolveMethodBody (RemObjects.Oxygene.Code.Compiler.ScopeInfo aScope, RemObjects.Oxygene.Code.IMethodImplementation aMethod) [0x01204] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.Compiler.Compiler+<>c__DisplayClass37.<ResolveMembers>b__5 (RemObjects.Oxygene.Code.IParsedType aType) [0x00102] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.Compiler.Compiler.ForAllInternalTypes (System.Action`1[T] aAt) [0x00068] in <382c322db5f24ae49ceb132b40caf56e>:0 
  at RemObjects.Oxygene.Code.Compiler.Compiler.ResolveMembers () [0x001f0] in <382c322db5f24ae49ceb132b40caf56e>:0 
	} // E287 Syntax error
} // E477 Declaration expected

can you just send me the whole project (you can PM, if its private).it just makes it so much easier, as creating test cases from snippets and vague descriptions always risks now showing the real issue.

thanx!