microsoft / microsoft/hlsl-specs

Spec does not mention the ability to elementwise convert an aggregate to a scalar

Open Beginner friendly
#809 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
TeX
Stars
222
Forks
57
Avg merge
4d 16h
Merged PRs (30d)
5

Description

Which document does this relate to?

Elementwise conversions

https://github.com/microsoft/hlsl-specs/blob/b7d50aceecc51e0a3d53bc4defa182449945b64e/specs/language/conversions.tex#L124-L125

Describe the issue you see with the spec

The spec states that a prvalue A can be elementwise converted to a prvalue of an aggregate B.
However, it does not mention that it is possible to elementwise convert prvalue A to a prvalue of a scalar (a non-aggregate type).

Additional context
https://hlsl.godbolt.org/z/qGoTPMshK

Given the following HLSL:

void fn() {
    int A[4] = {1, 2, 3, 4};
    int I = (int)A;
}

In the Clang AST, an elementwise conversion is used to convert the aggregate type (int[4]) into a scalar (int).

      `-VarDecl <col:5, col:18> col:9 I 'int' cinit
        `-CStyleCastExpr <col:13, col:18> 'int' <HLSLElementwiseCast>
          `-ImplicitCastExpr <col:18> 'int[4]' <HLSLArrayRValue> part_of_explicit_cast
            `-DeclRefExpr <col:18> 'int[4]' lvalue Var 0x1c037468 'A' 'int[4]'

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start with specs/language/conversions.tex at the Elementwise conversions section referenced in the issue, then compare its wording with the HLSL example and Clang AST output. Update the specification to state how an aggregate prvalue can be elementwise converted to a scalar prvalue, and verify that the documented rule covers the shown int[4] to int conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
tex
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.