Skip to content

Cascade implicit block hides missing do syntax errors #179

Description

@qqueue
a
 b
  c
   d
    e

compiles to

var x$, y$, z$, z1$;
x$ = a;
y$ = b;
z$ = c;
z1$ = d;
e;

even though the cascadee isn't used. This hides some typos involving a missing do that were previously caught at compile time, such as:

method
   arg1
   arg2
var x$;
x$ = method;
arg1;
arg2;

and even though this works when run, it hides the fact that |> doesn't actually accept an implicit block:

program = @createProgram! |>
    @attachShader _, vertex-shader
    @attachShader _, fragment-shader
    @linkProgram _
    unless @getProgramParameter _, LINK_STATUS
      throw new Error "couldn't intialize shader program!"
    @useProgram _
var x$, program, _;
x$ = (_ = program = this.createProgram(), this.attachShader(_, vertexShader));
this.attachShader(_, fragmentShader);
this.linkProgram(_);
if (!this.getProgramParameter(_, LINK_STATUS)) {
  throw new Error("couldn't intialize shader program!");
}
this.useProgram(_);

Proposal: cascade blocks in which the cascadee isn't used at least once should be invalid syntax. The error message should be similar to "Unexpected INDENT on line xx:xx, did you forget a 'do' or a cascade usage?"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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