Skip to content

[Dot Shorthands] non_constant_default_value #60962

Open
@RohitSaily

Description

@RohitSaily

Dart SDK version: 3.9.0-235.0.dev (dev) (Fri Jun 13 21:03:03 2025 -0700) on "macos_x64"

Consider

class T
{	const T();
}
void f([T t=T()]) // ERROR: non_constant_default_value
	{}

non_constant_default_value is reported as expected and can be resolved by changing [T t=T()] to [T t=const T()]. But if the experimental dot shorthand syntax is used to invoke the same constructor without the const keyword, no error is reported by the static analyzer via VSCode

void f([T t=.new()]) // no error :(
	{}

The error is only reported when trying to run the code

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.feature-dot-shorthandsImplementation of the dot shorthands feature.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions