Skip to content

array with {} syntax gets inlined wrong in function argument. #522

@wrightwriter

Description

@wrightwriter

Problem

A function taking a float[2] arr as an argument can not be called like:

fn({1.,2.});

It has to be called

fn(float[2](1.,2.));

Code

Input:

out vec4 fragColor;

float test(float[2] arr){
  float acc = 0.;
  for(int i = 0; i < 2; i++){
    acc += arr[i];
  }
  return acc;
}
void main() {
  float arr[2] = {1.,2.};
  
  fragColor.r = test(arr);
}

Output:

out vec4 f;|
float m(float[2] m){
  float f=0.;
  for(int r=0;r<2;r++)
    f+=m[r];
  return f;
}
void main(){
  f.x=m({1.,2.});
}

Expected output:

out vec4 f;|
float m(float[2] m){
  float f=0.;
  for(int r=0;r<2;r++)
    f+=m[r];
  return f;
}
void main(){
  f.x=m(float[](1.,2.));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions