Fire 8.3.92 (Beta) ERROR: E0: Internal error: An item with the same key has already been added

The “All” thing was fixed for the upcoming beta build already.

so for ifdefs:

#if cocoa
...
#endif

the 3 errors I have left:

issue73929_1.swift (76:32) E44 No member "map" on type "INSFastEnumeration<Promise>!"
issue73929_1.swift (231:32) E44 No member "enumerate" on type "Array<Promise!.thenClosure>!"
issue73929_1.swift (266:9) E399 No overloaded method "cat" with 1 parameter on type "Promise!"

I’ve logged an issue to expose/fix the map & enumerate apis. (bugs://73940)

THe other one I’ll be looking into too, cat is a block pointer, it should be invokable.

1 Like

Great! That would be super! As soon as there is the beta I will test it out!

About the cat here

private func doReject(error: AnyObject?, shouldRunFinally: Bool = true) {
        self.sync(self, closure: {
            if (self.status != .PENDING) { return }
            self.value = error
            
            self.cat?(self.value)
            if (shouldRunFinally) { self.doFinally(.REJECTED) }
        })
    }

I was trying another way to reference it, but no success so far.

Regarding the semaphone I can see here ( I didn’t get it before) that it is not a mapped type already:

http://docs.elementscompiler.com/Tutorials/Sugar/Bridging/

So I have to wait for this, right?

@ck Please expose the reduce function as well.
I was trying to do a map by myself, but got a "No Such member" of reduce here:

func map<T, S>(array: [T], f: (T->S)) -> [S] {
		return array.reduce([]) {
			(var seed, value) in
			seed.append(f(value))
			return seed
		}
	}

Yeah i logged the bug to update it to support the latest functionality.

1 Like

bugs://73929 got closed with status fixed.

Thats for the cat() thing.

@ck you’re welcome!
In the meanwhile waiting for the beta update, I did some small changes on the repo, reducing the error to (just) 4:

First, I have changed

var cat: catchClosure

directly to

var cat: (AnyObject?) -> ()

Then I replaced functional map, reduce, filter to ordinary for-loop statements:

                                   //let filteredNils = self.promises.filter( { (p) -> (Bool) in return (p.value != nil) } )
				var filteredNils = [AnyObject]()
				for el in self.promises {
					if(el.value != nil) {
						filteredNils.append(el.value!)
					}
				}
				
				//let values = filteredNils.map( { (p) -> (AnyObject) in print(p.value); return p.value! } )
				var values = [AnyObject]()
				for el in filteredNils {
					values.append(el)
				}

Last (4) errors are

/Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(58,3): error E121: Cannot instantiate interface type "Action2<Action1<AnyObject?>!,Action1<AnyObject?>!>!"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(62,11): error E43: No static member "All" on type "Promise"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(67,8): error E406: No overloaded method "then" with these parameters on type "Promise!", best matching overload is "then(_ then: Promise!.thenClosureNoReturn) -> Promise"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(167,32): error E44: No member "enumerate" on type "swift.Array<Promise!.thenClosure>!"

Last changes on

So basically the same errors as we already had for Cocoa too. I think the next update will make things a lot better.

Hello,
I have updated Fire to the lasted DMG on Mac, RemObjects Fire - 8.3.92.1905, Sat, Dec 19, 2015.
Considering the latest commit on the swift example for the Promise, https://github.com/loretoparisi/swift-promise-example
I report the following errors:

        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(58,3): error E121: Cannot instantiate interface type "Action2<Action1<AnyObject?>,Action1<AnyObject?>>!"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(62,11): error E43: No static member "All" on type "Promise"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(167,32): error E44: No member "enumerate" on type "swift.Array<Promise!.thenClosure>!"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(179,66): error E572: Cannot assign null to non-nullable "Action1<AnyObject?>"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(180,67): error E572: Cannot assign null to non-nullable "com.remobjects.elements.system.Action"
        /Volumes/MacHDD2/Developmemt/ParisiLabs/swift-promise-example/StaticLibrary/SharedProject/Promise.swift(311,23): error E500: Parenthesis are required to call method observe(), cannot assign method group to "Action1<Promise>"

Of course, I do not know if this beta came with issues described in this thread.

Thank you.

It did yes. but I solved pretty much only OSX/iOS issues.I’ll create a new bug to look at this too, but this week and next week are going to be busy so I can’t promise when I look at them.

Thanks, logged as bugs://73968

Thank you.
I can see that the following issues, seems to be new

error E121: Cannot instantiate interface type “Action2<Action1<AnyObject?>,Action1<AnyObject?>>!”
error E572: Cannot assign null to non-nullable “com.remobjects.elements.system.Action”

considering the previous build.

Thanks for your support!

I don’t see reduce() documented as API for Swifty anymore? https://developer.apple.com/library/mac/documentation/Swift/Reference/Swift_Array_Structure/index.html

Uhm right, that sounds weird since the project compiles and run on Xcode 7.1.1 (that I assume is running Swift 2.1), but actually I see that the lazy sequences

https://developer.apple.com/library/ios/documentation/Swift/Reference/Swift_LazySequenceType_Protocol/

now have only these methods

filter(_:)
flatMap(_:)
flatten()
map(_:)

Also there are changes in the latest iOS 9.2:

https://developer.apple.com/library/ios/releasenotes/General/iOS92APIDiffs/Swift/Swift.html

Among them:

Added SequenceType.filter(_: (Self.Generator.Element) throws -> Bool) rethrows -> [Self.Generator.Element]
Added SequenceType.filter(_: (Self.Generator.Element) throws -> Bool) rethrows -> [Self.Generator.Element]
Added SequenceType.map<T>(_: (Self.Generator.Element) throws -> T) rethrows -> [T]
Added SequenceType.map<T>(_: (Self.Generator.Element) throws -> T) rethrows -> [T]

while in iOS 9.1 there were a lot of changes :frowning:

https://developer.apple.com/library/ios/releasenotes/General/iOS91APIDiffs/Swift/Swift.html

BTW, in Swift REPL I can do:

Last login: Mon Dec 21 23:40:38 on ttys001
macbookproloreto:~ admin$ swift
Welcome to Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81). Type :help for assistance.
  1> print( ["one","two","three"].reduce("",combine:{$0 + $1}) )
onetwothree

In any case, i implemented reduce() and join() for Array yesterday ;).

1 Like
error E121: Cannot instantiate interface type "Action2&lt;Action1&lt;AnyObject?&gt;,Action1&lt;AnyObject?&gt;&gt;!"

this looks like a compiler bug; logging.

error E500: Parenthesis are required to call method observe(), cannot assign method group to "Action1&lt;Promise&gt;"

this too. the method SHOULD be assignable to the closure. will log.

error E43: No static member "All" on type "Promise"

this looks like a valid bug. what’s All supposed to be? i don’t see it defined

error E44: No member "enumerate" on type "swift.Array&lt;Promise!.thenClosure&gt;!"

this one’s a missing function in the base library; will implement. although to be honest i don’t quiet GET what this function is supposed to do. other than return the same sequence again?

error E572: Cannot assign null to non-nullable "Action1&lt;AnyObject?&gt;"
error E572: Cannot assign null to non-nullable "com.remobjects.elements.system.Action"

these are valid too. bur closure’s are not defined to be nullable. so you cant set them to nil. changing them to

var cat: catchClosure?
var fin: finallyClosure?

fixes it.

Thanks a lot, we are almost done then!
The nullable fixes the var definitions. The enumerate function from Swift 2.1 works on a collection returning the index and the value. It is not supposed to work on mutable collections.
So in the meanwhile I have replaced it with a fast enumerator

for (_, then) in self.thens.enumerate() {
//...
}

that is simple as

for then in self.thens.enumerate() {

}

So at this stage, we have 3 errors on the updated repo:

/StaticLibrary/SharedProject/Promise.swift(56,3): error E121: Cannot instantiate interface type "Action2<Action1<AnyObject?>,Action1<AnyObject?>>!"
        /StaticLibrary/SharedProject/Promise.swift(60,11): error E43: No static member "All" on type "Promise"
        /StaticLibrary/SharedProject/Promise.swift(309,23): error E500: Parenthesis are required to call method observe(), cannot assign method group to "Action1<Promise>"

         0 Warning(s)
         3 Error(s)

I was trying the new lock feature ( http://docs.elementscompiler.com/Silver/LanguageExtensions/Lock/ )

                 let mylock = Object();
		__locking mylock {
		  // thread sensitive operations.
		}

but I get this syntax error in Fire 8.3.92 Beta:

  /StaticLibrary/SharedProject/Promise.swift(120,13): error E504: Semicolon (;) required to separate two statements on the same line

The idea was to implement the same logic I was doing now like

func sync(lock: AnyObject!, @noescape closure: () -> ())  {
#if cocoa
		objc_sync_enter(lock)
		defer {
			objc_sync_exit(lock)
		}
		closure()
#else if java
		fsync(lock, closure)
#endif
	}

where in java I was using a file system lock file.

Ah, so

	@warn_unused_result public func enumerate() -> ISequence<(Int, T)> {
		var index = 0
		for element in self {
			__yield (index, element)
		}
	}

should do? i missed that subtlety from the docs. (coz frankly, how this is defined in the docs make this next to unparsable). Fixed in github and for the next beta.

Will have a look again.

i’ll check. maybe this wasn’t in the beta you had, yet? Update it’s not in mine either. Sure this was supposed too have bene implemented yet?

Right, according to the docs it should have been in 8.2 stable, I have 8.3 beta and __locking is not there. Is correct?

it’s __lock, not __locking.

 let mylock = Object();
__lock mylock {
  / thread sensitive operations.
}