Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Error (Fatal): An error occurred while parsing EntityName. Line 524, position 45. (XmlException) #154

Open
rolfbjarne opened this issue Apr 12, 2018 · 2 comments
Milestone

Comments

@rolfbjarne
Copy link
Member

Test case:
AlecrimCoreData.zip

Repro: unzip & make all TOOL_LIB=/path/to/swift-o-matic

Result: https://gist.github.com/rolfbjarne/10d91414438c2af72060e0343a1bd60b

Source: https://github.com/Alecrim/AlecrimCoreData

@chamons
Copy link
Contributor

chamons commented Sep 13, 2018

I did some looking and I've isolated two test cases:

public typealias ManagedObject = NSManagedObject

public struct Query<Entity: ManagedObject> {
    
    public init() {}
    
    public func makeIterator() -> QueryIterator<Entity> {
        return QueryIterator([])
    }
    
    public struct QueryIterator<Entity>: IteratorProtocol {
           fileprivate init(_ entities: [Entity]) {}
        public mutating func next() -> Entity? { return nil; }
    }
}

gives

SwiftRepro-Query-QueryIterator.swift:5:53: error: reference to generic type 'Query' requires arguments in <...>
    UnsafeMutablePointer<Optional<U0>>, this: inout Query.QueryIterator<U0, 
                                                    ^
                                                         <NSManagedObject>
SwiftRepro.Query:1:15: note: generic type 'Query' declared here
public struct Query<Entity> where Entity : ManagedObject {
              ^
 (Exception)
Error (Fatal): Failed to wrap module SwiftRepro. (CompilerException)

and

public typealias ManagedObject = NSManagedObject

public struct Query<Entity: ManagedObject> {
    
    public init() {}
    
    public func makeIterator() -> QueryIterator<Entity> {
        return QueryIterator([])
    }
}

extension Query {
       public struct QueryIterator<Entity>: IteratorProtocol {
       fileprivate init(_ entities: [Entity]) {}
       public mutating func next() -> Entity? { return nil; }
    }
}

gives

Warning: unexpected error handling __T011XamWrapping34xamarin_QueryDmakeIterator00000001ySpy10SwiftRepro0D0V0D8IteratorVyx_xGG6retval_AEyxGz4thistSo15NSManagedObjectCRbzlF: Expected a nominal type node kind but got BoundGenericStructure
Parameter name: node, skipping. (ArgumentOutOfRangeException)
Warning: entry __T011XamWrapping34xamarin_QueryDmakeIterator00000001ySpy10SwiftRepro0D0V0D8IteratorVyx_xGG6retval_AEyxGz4thistSo15NSManagedObjectCRbzlF uses an unsupported swift feature, skipping. (NotSupportedException)

But I've been unable to isolate the exact error except from the entire binary (though I've reproduced it).

@stephen-hawley stephen-hawley transferred this issue from another repository Oct 29, 2019
@chamons chamons added this to the Future milestone Nov 14, 2019
@stephen-hawley
Copy link
Contributor

Here's what's going on here for future Steve:

The problem is in demangling the nested generic type and the problem is not small, unfortunately. This sample has the type SomeModule.Query<Entity>.QueryIterator<Entity>

This problem is the generic within the nesting of names. The modeling that we have for a swift class is a module followed by all the types that it is nested within. The nesting mechanism is fairly simple: a list of names and a list of what kind of entity they are (struct, enum, protocol, class), but that model is wrong since it doesn't account for the possibility that one of the elements might be generic. So the modeling of this has to change. For future Steve, probably the best way to do this is to consider losing the SwiftClassName type entirely and build one that has a module name and a List<SwiftType> for each element. This refactoring will break a great many things, which is why I'm not touching it now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants