Skip to content

Reject dictionaries passed as lists#28969

Open
keith wants to merge 1 commit intobazelbuild:masterfrom
keith:ks/reject-dictionaries-passed-as-lists
Open

Reject dictionaries passed as lists#28969
keith wants to merge 1 commit intobazelbuild:masterfrom
keith:ks/reject-dictionaries-passed-as-lists

Conversation

@keith
Copy link
Member

@keith keith commented Mar 12, 2026

Previously it was valid to pass a dictionary to a starlark attribute
defined with attr.string_list, previously it would take its keys. Now
it is rejected.

Fixes #17553

Previously it was valid to pass a dictionary to a starlark attribute
defined with `attr.string_list`. In this case it would be ignored. Now
it is rejected.

Fixes bazelbuild#17553
@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Mar 12, 2026
@iancha1992 iancha1992 added the team-Rules-CPP Issues for C++ rules label Mar 12, 2026
@fmeum
Copy link
Collaborator

fmeum commented Mar 13, 2026

Prior to this PR, was it really ignored or turned into a list of its keys?

@keith
Copy link
Member Author

keith commented Mar 13, 2026

you're right, it turned the list into its keys. i thought i had checked that. so this example:

cc_library(
    name = "foo",
    srcs = ["foo.cc"],
    copts = ["-v"],
    defines = {"FOO": "bar"},
)

gets -DFOO (instead -DFOO=bar)

I think that means we should merge but not try to cherry pick and let this happen in 10.x. wdyt?

@keith
Copy link
Member Author

keith commented Mar 13, 2026

if the user wants the existing behavior they can change their code to:

defines = {"FOO": "bar"}.keys(),

after this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cc_library defines should reject dict argument

3 participants