PRQL/prql · error · Error

expected a value, found a type

Error message

expected a value, found a type

What it means

The resolver distinguishes types from values. When an expression resolves to a declaration whose kind is `DeclKind::Ty` (a type), but a value is required in that position, this error is thrown. Types are not first-class values in PRQL.

Solutions

  1. Remove the type name from value position or replace it with an actual expression/value
  2. If a cast/conversion was intended, use the appropriate function (e.g. `std.int` cast via `+ : int` annotation on params or conversion functions)
  3. Check for shadowing: a column sharing a name with a type

Example fix

// before
select int
// after
select x | cast int  # or annotate types only on function params
Defensive patterns

Strategy: type-guard

Validate before calling

// Do not use type keywords in value positions
const TYPE_NAMES = ["int","float","bool","text","date","timestamp"];
if (TYPE_NAMES.includes(selectedColumn)) {
  throw new Error(`${selectedColumn} is a type, not a value; check for shadowing`);
}

Type guard

function isTypeReference(node, types) {
  return node.kind === "ident" && types.has(node.name);
}

Try / catch

try {
  compile(query);
} catch (e) {
  if (e.message.includes("expected a value, found a type")) {
    console.error("Types only belong in `:` annotations, not value expressions.");
  } else { throw e; }
}

Prevention

When it happens

Trigger: Using a type name as a value, e.g. `select int` or `derive x = date`, outside of a type-annotation context (the `who` slot of a func param or `typeof`).

Common situations: Accidentally selecting a column named like a type, or confusing type annotations (after `:`) with value expressions.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of PRQL/prql@e164e249b9 (2026-09-09). Data as JSON: /api/errors/68999b8cfd56230e. Report an issue: GitHub.

Appendix: source

Thrown at prqlc/prqlc/src/semantic/resolver/expr.rs:155

                            }
                        }
                        _ => self.fold_expr(expr.as_ref().clone())?,
                    },

                    DeclKind::InstanceOf(_, ty) => {
                        let ty = ty.clone();

                        let fields = self.construct_wildcard_include(&fq_ident);

                        pl::Expr {
                            kind: pl::ExprKind::Tuple(fields),
                            ty,
                            ..node
                        }
                    }

                    DeclKind::Ty(_) => {
                        return Err(Error::new(Reason::Expected {
                            who: None,
                            expected: "a value".to_string(),
                            found: "a type".to_string(),
                        })
                        .with_span(span));
                    }

                    _ => pl::Expr {
                        kind: pl::ExprKind::Ident(fq_ident),
                        ..node
                    },
                }
            }

            // special case: handle the syntax !{tuple..} via resolve_column_exclusion
            pl::ExprKind::FuncCall(pl::FuncCall {
                name,
                args,

View on GitHub (pinned to e164e249b9)