Skip to content

Print a warning when comma operators are used for an expression other than for-loop #6732

@jkwak-work

Description

@jkwak-work

Problem description

The following code is not written as intended.

float4 vColor = (0.f, 0.f, 0.f, 1.f);

It should be with braces not parenthesis like the following,

float vColor = { 0.f, 0.f, 0.f, 1.f };

When the parenthesis is used, it is not entirely incorrect from the syntax perspective.
The expression ( 0.f, 0.f, 0.f, 1.f ) is treated as four expressions connected with comma-operators.
And the last expression, which is 1.f in this case, is used as a value to float vColor.

Although it is a mistake on the user side, it will be nice to print a warning to inform the possible mistake.

Possible solution

A suggested solution from Yong is to allow comma-operators only in for-loop.
And when comma-operators are used elsewhere, we should print a warning that the user can also suppress if needed.

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions