default null syntax

Open
#1,233 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
compilers

Research direction

No files, tests, or entry points are named. Start by reviewing how nullable ?. access and missing-field errors currently behave, then determine whether the requested behavior belongs in new obj.b? or obj["b"?] syntax or in std.get; done requires an agreed direction and corresponding verified behavior.

Written by the indexing model from the issue text.

Description

Motivation: when ?. is means we can call select on a nullable value, but it still throws Field does not exists exception.

What about using a obj.b? or obj['b'?] syntax to express: if bdoes not exists inobj, then returnnull` instead of an error.

  • obj.b?
  • obj["b"?]

or, we can just use std.get method

Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/jsonnet

All issues in google/jsonnet

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.