Skip to content

Commit 6b93053

Browse files
committed
feat(glsl): ignore const declaration on functions
1 parent a3cd3f7 commit 6b93053

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/glsl/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ function handleAssign(node, kind) {
291291
if (init.type === 'ArrowFunctionExpression') {
292292
typeAnnotation = init.returnType;
293293
allocation = handleNode(init);
294+
kind = undefined;
294295
} else {
295296
allocation = handleAlloc(init, typeAnnotation, name);
296297
}

test/glsl/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void main() {
163163

164164
it('works with struct', () => {
165165
const { glsl } = buildGLSL(() => {
166-
let MyType = cls({
166+
const MyType = cls({
167167
fNormal: vec3,
168168
vNormal: vec3
169169
});
@@ -274,12 +274,26 @@ vec2 bar(vec2 x, float y) {
274274
const foo = uniform(vec2(0.0));
275275
const bar = vec2(0.0);
276276
let baz = vec2(0.0);
277+
278+
const fnFloat = float(() => {
279+
return 5.0;
280+
});
281+
282+
const fnFVoid = () => {
283+
5.0 + 7.0;
284+
};
277285
});
278286

279287
const expected = `
280288
uniform vec2 foo = vec2(0.0);
281289
const vec2 bar = vec2(0.0);
282290
vec2 baz = vec2(0.0);
291+
float fnFloat() {
292+
\treturn 5.0;
293+
}
294+
void fnFVoid() {
295+
\t5.0 + 7.0;
296+
}
283297
`;
284298
assert.equal(glsl.trim(), expected.trim());
285299
});

0 commit comments

Comments
 (0)