From 6e3c24dee3f859bd7555f87884c86223e90196a7 Mon Sep 17 00:00:00 2001 From: Aryan Baranwal Date: Thu, 30 Apr 2026 11:27:29 +0530 Subject: [PATCH] fix(sema): reject rational expressions in abi.encode* arguments Signed-off-by: Aryan Baranwal --- src/sema/builtin.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/sema/builtin.rs b/src/sema/builtin.rs index 91d68758a..18f5160ce 100644 --- a/src/sema/builtin.rs +++ b/src/sema/builtin.rs @@ -1413,6 +1413,15 @@ pub(super) fn resolve_namespace_call( return Err(()); } + if matches!(ty, Type::Rational) { + diagnostics.push(Diagnostic::error( + arg.loc(), + "rational expression has no concrete type, cast to an integer type before encoding" + .to_string(), + )); + return Err(()); + } + expr = expr.cast(&arg.loc(), ty.deref_any(), true, ns, diagnostics)?; // A string or hex literal should be encoded as a string