Skip to content

Transpiler bug: Transpiled code misses a period '.' #19

@lexum0

Description

@lexum0

Description

The code fails to compile due to it missing a period '.' or the full definition (period and the struct it belongs to). e.g. Typing .id will be transpiled as 'id' instead of Country.CodingKeys.id, causing different errors since it doesn't exist.

The problem only seems to appear in a try call when the function throws.
Functions like update() and insert() produce the error, while select() works correctly, as the following test shows:

Test

  1. Add the following code at the bottom of the ContentView file in the SupaTODO project
    https://github.com/skiptools/skipapp-supatodo/blob/main/Sources/SupaTODO/ContentView.swift
func test1() throws -> PostgrestFilterBuilder {
    supabase
        .from("table")
        .select() // select works
    
        .eqCol(.name, value: "") // ✅
}
func test2() throws -> PostgrestFilterBuilder {
    try! supabase
        .from("table")
        .update("") // update doesn't work
    
//        .eqCol(Key.name, value: "") // works
        .eqCol(.name, value: "") // ❌ <- Transpiler error: '.' is missing in the transpiled code (in the .kt file)
}
func test3() throws -> PostgrestFilterBuilder {
    try! supabase
        .from("table")
        .insert("") // insert doesn't work
    
        .eqCol(Key.name, value: "") // works
//        .eqCol(.name, value: "") // ❌ <- Transpiler error: '.' is missing in the transpiled code (in the .kt file)
}

enum Key: String {
    case id,
         name
}
extension PostgrestFilterBuilder {
    func eqCol(_ column: Key,
               value: String) -> PostgrestFilterBuilder {
        eq(column.rawValue, value: value)
    }
}
  1. Compile the project and open the transpiled ContentView.kt file.
    The transpiled code will show .eqKey(name instead of .name or Key.name_

  2. Uncomment the previous line to see it work correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions