                         return
                     }
                     // Attempt to interpret as a color expression
-                    guard let parsedExpression = try? parseExpression(name) else {
+                    guard let _parsedExpression = try? parseExpression(name) else {
                         throw Expression.Error.message("Invalid color name `\(name)`")
                     }
-                    self.init(
-                        anyExpression: parsedExpression,
-                        type: type,
-                        nullable: false,
-                        symbols: colorSymbols,
-                        lookup: colorLookup,
-                        for: node
-                    )
-                case let .expression(parsedExpression):
-                    guard let anyExpression = LayoutExpression(
-                        anyExpression: parsedExpression,
-                        type: RuntimeType(Any.self),
-                        nullable: false,
-                        symbols: colorSymbols,
-                        lookup: colorLookup,
-                        for: node
-                    ) else {
-                        return nil
-                    }
-                    self.init(
-                        evaluate: {
-                            switch try unwrap(anyExpression.evaluate()) {
-                            case let name as String:
-                                return try nameToColorAsset(name)
-                            case let color:
-                                return try cast(color, as: type)
-                            }
-                        },
-                        symbols: []
-                    )
+                    parsedExpression = _parsedExpression
+                case let .expression(_parsedExpression):
+                    parsedExpression = _parsedExpression
                 case .comment:
                     return nil
                 }
-            } else if #available(iOS 11.0, *) {
-                guard let nameExpression = LayoutExpression(stringExpression: colorExpression, for: node) else {
+                guard let expression = LayoutExpression(
+                    anyExpression: parsedExpression,
+                    type: RuntimeType(Any.self),
+                    nullable: false,
+                    symbols: colorSymbols,
+                    lookup: colorLookup,
+                    for: node
+                ) else {
                     return nil
                 }
                 self.init(
                     evaluate: {
-                        try nameToColorAsset(nameExpression.evaluate() as! String)
+                        switch try unwrap(expression.evaluate()) {
+                        case let name as String:
+                            return try nameToColorAsset(name)
+                        case let color:
+                            return try cast(color, as: type)
+                        }
                     },
-                    symbols: []
+                    symbols: expression.symbols
+                )
+            } else if #available(iOS 11.0, *) {
+                guard let expression = LayoutExpression(stringExpression: colorExpression, for: node) else {
+                    return nil
+                }
+                self.init(
+                    evaluate: { try nameToColorAsset(expression.evaluate() as! String) },
+                    symbols: expression.symbols
                 )
             } else {
                 throw Expression.Error.message("Named colors are only supported in iOS 11 and above")

        do {
            let parts = try parseStringExpression(colorExpression)
            if parts.count == 1 {
                switch parts[0] {
                case let .string(name):
                    if let color = try stringToColorAsset(name) {

    #endif
    if asset.bundle != nil {
        throw Expression.Error.message("Named colors are only supported in iOS 11 and above")
    }
    return nil
}

private var _imageAssetCache = NSCache<NSString, UIImage>()
func stringToImageAsset(_ string: String) throws -> UIImage? {
    if let image = _imageAssetCache.object(forKey: string as NSString) {
        return image
    }
    let (name, bundle, traits) = try stringToAsset(string)
    if let image = UIImage(named: name, in: bundle, compatibleWith: traits) {
        _imageAssetCache.setObject(image, forKey: string as NSString)
        return image
    }
    if let bundle = bundle {
        throw Expression.Error.message("Image named `\(name)` not found in bundle \(bundle.bundleIdentifier ?? "<unknown>")")
    }
    return nil
}
