Skip to content

X=1,2;X does not error even though 2 is unused #57

Description

@jkeiser

X=1,2;X will assign X=1 and then create a stream (),2, so the output of this is 1. X=(1,2) work as expected.

This should either assign both 1 and 2 to X, or forbid the construction altogether. X = 1,2, X = 1 , 2, and X = 1, 2 should do the same thing as X=1,2.

A few possible solutions:

  • The program could output (1,2)
  • It could be an error to assign inside a comma at the same precedence level (X=1,2 or X = 1, 2).
  • It could be an error to leave a value unused anywhere.
  • The program could return the stream 2,1 because there are 2 statements that return values. In this case, () cannot be a value. This might be a wonderful idea, but we still need something more targeted to tell the user that X=1,2 isn't doing what it looks like it should.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions