Skip to content

[DEV BUG] HLSLParser: Expression in declaration causes parsing error #940

@kblaschke

Description

@kblaschke

Affected Project

libprojectM (including the playlist library)

Operating Systems and Architectures

All

Type of Defect

Specific bug in projectM code (please link the code in question)

Describe the Issue

The HLSLParser class has an obvious issue parsing declarations which also contain additional expressions such as this example:

float scalar = 2.0;
float2 var = (float2(x, y)) * scalar;

HLSLParser will raise a parsing error at the *, saying it expects ; (end-of-statement) instead, while this line is totally fine in HLSL and, once transalated, in GLSL as well, which would look like this:

float scalar = 2.0;
vec2 var = (vec2(x, y)) * scalar;

HLSLParser fails at the end of this block at return Expect(';');.

The issue probably resides in the The ParseDeclaration() function, which seemingly doesn't expect additional code besides a simple assignment.

A proper fix would make the function aware of any additional expressions which might be within the declaration's rvalue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue is (potentially) a bug.

    Type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions