Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Allow list initializer as function argument.

未关闭
#1,906 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
compilers

调研方向

复现程序位于 test.osl 中,并通过 oslc 进行编译;首先运行报告中的命令,以确认针对花括号参数的诊断信息。跟踪编译器如何处理正常工作的 initializer-list 情况与函数调用参数,然后确认使用花括号 vector 参数时示例能够成功编译。

由索引模型根据 Issue 内容生成。

描述

Problem

Initializer lists are not allowed as function arguments, would be nice if they were, and would possibly simplify some of the MaterialX code base for OSL code generation.

struct vector2
{
    float x;
    float y;
};

void NG_switch_vector2I(vector2 in1, vector2 in2, vector2 in3, output vector2 out)
{
    out = in1;
}

shader test_shader
(
    vector2 input = {1,2},              // this works
    output float out = 0
)
{
    vector2 outVec;
    vector2 in1 = {0,1};                // this works

    NG_switch_vector2I(
        in1,                            // this works
        vector2(0.000000, 0.000000),    // this works
        {0.000000, 0.000000},           // this doesn't work
        outVec);

    out = outVec.x;
}

Expected behavior:
I expected this to compile just fine...

Actual behavior:
But it didn't... I get the following compile error.

 > oslc test.osl
test.osl:24: error: Cannot construct type 'unknown'
FAILED test.osl
Steps to Reproduce
  1. Compile the shader code above
  2. Get compile error
Versions
  • OSL branch/version: 1.13.8.0
  • OS: MacOS Sequoia
  • C++ compiler:
  • LLVM version: 17.0.6
  • OIIO version: 2.5.9.0
主要语言
C++
星标
2.3k
派生
415
平均合并
2 天 10 小时
30 天内合并 PR
14

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AcademySoftwareFoundation/OpenShadingLanguage 的其他 Issue

查看 AcademySoftwareFoundation/OpenShadingLanguage 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。