Object reference not set to an instance of an object

just updated to swift3 and Fire 2151… (for an iOS android project)
after all my code looks like it’s compiled in Fire I get this :frowning:

/Applications/Fire.app/Contents/Resources/XbuildTargets/RemObjects Software/Elements/RemObjects.Elements.Cooper.Common.targets: error : Object reference not set to an instance of an object at RemObjects.Oxygene.Code.Compiler.Compiler.m () [0x00266] in :0
at RemObjects.Oxygene.MSBuild.OxygeneCompiler.Execute () [0x00818] in :0

unfortunately since I just converted about 90K lines, I don’t know which one is causing the problem :frowning:

Hmm, that looks like a compiler bug. Can you send us the project in question, and.or post the full (“Diagnostic”) build log? If you have beta access, could you also try the latest beta/gamma instead of .2151?

thanx,
marc

Hi Marc,

unfortunately IP restrictions mean I can’t send you the project. If I can narrow it down I can send you a fragment.
I don’t have beta access… but I would like to. How do I get that? (I used to have it at asdeq labs.)

Paul

The full log might help in the mean time. Betas are avaiable to all paid customers at http://beta.remobjects.com, but i can otherwise send you the latest beta tomorrow — what’s your remobjects.com account name?

asdeqpaul

by diagnostic build log do you mean just build log? or is there another one?

I noticed the bug is here:

Entering phase “Generating Output” (00:00:00.1392744)
/Applications/Fire.2151.app/Contents/Resources/XbuildTargets/RemObjects Software/Elements/RemObjects.Elements.Cooper.Common.targets: error : Object reference not set to an instance of an object at RemObjects.Oxygene.Code.Compiler.Compiler.m () [0x00266] in :0
at RemObjects.Oxygene.MSBuild.OxygeneCompiler.Execute () [0x00818] in :0
Task “OxygeneCompiler” execution – FAILED

I found the diagnostic setting…
for IP reasons can I email it to you instead of posting?

also didn’t mention… but it says at the end of the log…

Saving XML details to /var/folders/rg/dlhkp15j5zn9w_4z9pr41kxc0000gp/T/PaymentShared.fire.temp.sln.xml

but that file is not present.
no idea if that is related.

sure pls send it to mh@remobjects.com. i’ll have a look tomorrow and also send you the beta, then. thanx!

no that’s normal. fire reads that file and then deletes it, it’s used for things like auto-fixit errors. i should probably drop that message again :wink:

got it down to one line.
I’ll see if I can get it more generic first but

let x = y ?? a.b.c

crashes Fire after compiling

var x = y
if x == nil { x = a.b.c }

doesn’t

ok, making sense…

let x = y ?? a.b.c

but c is an optional… no wonder it gets confused…
and no wonder it gets a NPE… I would expect the rhs of the ?? to evaluate to a non optional for sure

class X
{
    var a: Int?
    var b: Int?
}

var a: Int? = 1
var b: Int? = 2

func f()
{
    // crash
    //let c = a ?? b
    
    //crash
    //var c = a ?? b
    
    //crash
    //let x = X()
    //let c = x.a ?? x.b
    
    //crash
    //let x: X? = X()
    //var c = x?.a
    //c = c ?? x?.b
    
    // OK
    //var c = a
    //if c == nil { c = b }
    
    //crash
    //let c: Int? = a ?? b
    
    // OK
    let c = a ?? b ?? 0
}

so here is the outcome of some research…

basically it appears that if the rhs (final outcome) of a ?? is optional there is a problem.

hrmm oke i tried this:

class X
{
    var a: Int?
    var b: Int?
}

var a: Int? = 1
var b: Int? = 2

func f()
{
    // crash
    let c1 = a ?? b
    
    //crash
    var c2 = a ?? b
    
    //crash
    let x = X()
    let c3 = x.a ?? x.b
    
    //crash
    let x2: X? = X()
    var c4 = x2?.a
    c4 = c4 ?? x2?.b
    
    // OK
    var c5 = a
    if c5 == nil { c5 = b }
    
    //crash
    let c6: Int? = a ?? b
    
    // OK
    let c7 = a ?? b ?? 0
}

f()

as iOS, OSX and .NET app; neither seems to crash the compiler, so I must be missing a step. or it’s something we already fixed since. Just in case, can you send me the test project above as -is that crashes?

Carlo,
should have mentioned… building for Android.

yep, it crashes with this simple file…

make an Android project.

add this to main activity

public override func onCreate(_ savedInstanceState: Bundle!) {
	super.onCreate(savedInstanceState)
	ContentView = R.layout.main
	
	let a: Int? = nil
	let b: Int? = nil
	
	let c = a ?? b
}

build.
it will get NPE

                            Entering phase "Inlining code" (00:00:00.0343176)
                            Entering phase "Pre-Simplifying Code" (00:00:00.0040031)
                            Entering phase "Simplifying Code" (00:00:00.0057093)
                            Entering phase "Flow Analysis" (00:00:00.0231068)
                            Entering phase "Generating Output" (00:00:00.0094753)

: error E0: Internal error: Object reference not set to an instance of an object
Task “OxygeneCompiler” execution – FAILED

org.me.androidapplication.zip (104.1 KB)

Carlo,

also… I have the MAC version

Paul

Confirmed, that project reproduces the NRE here for me, with latest.