{"record":{"id":"6c38555dcb2b114c","repo":"PRQL/prql","slug":"expected-expected-ty-found-found-ty","errorCode":null,"errorMessage":"expected {expected_ty}, found {found_ty}","messagePattern":"expected (.+?), found (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/semantic/resolver/types.rs","lineNumber":205,"sourceCode":"{\n    fn display_ty(ty: &Ty) -> String {\n        if ty.name.is_none() {\n            if let TyKind::Tuple(fields) = &ty.kind {\n                if fields.len() == 1 && fields[0].is_wildcard() {\n                    return \"a tuple\".to_string();\n                }\n            }\n        }\n        format!(\"type `{}`\", write_ty(ty))\n    }\n\n    let who = who();\n    let is_join = who\n        .as_ref()\n        .map(|x| x.contains(\"std.join\"))\n        .unwrap_or_default();\n\n    let mut e = Error::new(Reason::Expected {\n        who,\n        expected: display_ty(expected),\n        found: display_ty(found_ty),\n    });\n\n    if found_ty.kind.is_function() && !expected.kind.is_function() {\n        let found = found_ty.kind.as_function().unwrap();\n        let func_name = if let Some(func) = found {\n            func.name_hint.as_ref()\n        } else {\n            None\n        };\n        let to_what = func_name\n            .map(|n| format!(\"to function {n}\"))\n            .unwrap_or_else(|| \"in this function call\".to_string());\n\n        e = e.push_hint(format!(\"Argument might be missing {to_what}?\"));\n    }","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/semantic/resolver/types.rs#L187-L223","documentation":"Generic type-check failure in the resolver: an expression's inferred type did not match the type expected by a transform or function argument. The `who` context usually names the offending construct (e.g. a `std.join` argument), and special hints are added when a function was found where a non-function type was expected (e.g. forgetting to call it).","triggerScenarios":"Passing a wrong-typed argument to any transform — e.g. `join side:...` receiving a non-table, comparing incompatible types in `filter`, or giving a function object where a value/column type is required.","commonSituations":"Joining on a non-table expression, passing a lambda where a column is expected, mixing text and numeric literals in comparisons, or forgetting parentheses to invoke a table-returning function.","solutions":["Read `who` and the expected/found types in the full error; align the argument's type with the expected one.","If a function was found where a value was expected, call it: add parentheses and arguments.","Cast or convert the value (e.g. wrap numbers in `std.int` text conversions) when types are close but not identical.","Check the docs for the transform's argument signature (e.g. `std.join` needs tables plus join keys)."],"exampleFix":"// before\njoin other (x -> x.id == id)\n// after\njoin other (side:left, x.id == id)","handlingStrategy":"validation","validationCode":"// check argument types against the transform signature before generating PRQL\nif (!matchesExpectedType(arg.type, signature[transform][param])) throw new Error(`param ${param} of ${transform} must be ${signature[transform][param]}`);","typeGuard":"const isFunctionExpr = (e) => e.kind === 'func' || e.kind === 'lambda';\n// if isFunctionExpr(arg) and a value is expected, the call is missing invocation","tryCatchPattern":"try { compile(prql) } catch (e) { if (e.message.includes('found') && e.message.includes('expected') && e.annotations?.who?.includes('std.join')) { /* fix join argument types */ } }","preventionTips":["Read the `who:` context in the error to locate the offending argument","Verify transform argument signatures in the PRQL stdlib docs","Add parentheses when a function/lambda must be invoked rather than passed","Run prqlc compile on generated queries in CI to catch type errors early"],"tags":["prql","compile-time","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"e164e249b99485890036eb60f57c37520379b240","analyzedAt":"2026-09-09T12:18:38.727Z","contentChangedAt":"2026-09-09T12:18:38.727Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}