Skip to content

Commit

Permalink
compiler: panic arguments are empty interface type
Browse files Browse the repository at this point in the history
After CL 536643 passing NULL as the expected type permitted an untyped
constant expression to remain untyped. Change to passing the empty
interface type.

The panic and print/println functions are the only builtin functions
that turn an untyped constant expression into a regular function call,
and we already handled print/println specially.

The test case is https://go.dev/cl/603096.

Fixes golang/go#68734

Change-Id: I02f353425b1f4cb8253ab7b29d707d93ede62f72
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/603215
Reviewed-by: Than McIntosh <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
ianlancetaylor authored and Ian Lance Taylor committed Aug 5, 2024
1 parent faf214a commit 5f6fae5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go/expressions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11137,6 +11137,12 @@ Builtin_call_expression::do_determine_type(Gogo* gogo,
is_print = false;
break;

case BUILTIN_PANIC:
arg_type =
Type::make_empty_interface_type(Linemap::predeclared_location());
is_print = false;
break;

case BUILTIN_PRINT:
case BUILTIN_PRINTLN:
// Do not force a large integer constant to "int".
Expand Down

0 comments on commit 5f6fae5

Please sign in to comment.