Skip to content

dict.update should return None, not self #18

@alandonovan

Description

@alandonovan

In .bzl files, the expression dict(a=1).update(b=2) evaluates to {a: 1, b: 2} but according to
https://github.com/bazelbuild/starlark/blob/master/spec.md#dictupdate
it should return None.

Both Pythons and Starlark-in-Go return None:

$ python # 2 or 3

x = {}
x.update(k=1)
x
{'k': 1}

$ starlark # in Go

x = {}
x.update(k=1)
x
{"k": 1}

The Java standalone interpreter gives a strange error --- I have no idea what it means:
% blaze-bin/third_party/bazel/src/main/java/com/google/devtools/skylark/Skylark

x = {}
x.update(k=1)
parameter 'other' has no default value, in method call update(int k) of 'dict'

Googlers: see L23 of dart_dev_ctx.bzl in cr/223363742 for a real-world example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions