Skip to content

Tuple-destructure into existing variables #136

Closed

Description

@mr-zwets

It would be clean if cashscript allowed to redefine variables in tuples, for example:

bytes variableA = 0x00;
bytes variableB = 0x00;
if(condition){
  variableA,variableB = bytesequence.split(index); 
}

Currently the workaround is

bytes variableA = 0x00;
bytes variableB = 0x00;
if(condition){
  variableA = bytesequence.split(index)[0]; 
  variableB = bytesequence.split(index)[1];
}

Activity

  1. added this to the v1 milestone on Nov 8, 2023
  2. removed this from the v1 milestone on Sep 23, 2024
  3. added this to the v0.12.0 milestone on Jan 15, 2025
  4. removed this from the v0.12.0 milestone on Jan 29, 2025
  5. added this to the v0.14.0 milestone on Jun 19, 2026
  6. changed the title [-]Can't redefine variables in tuples[/-] [+]Tuple-destructure into existing variables[/+] on Jun 26, 2026
  7. mr-zwets commented on Jun 26, 2026

    @mr-zwets
    MemberAuthor

    renamed the issue "Tuple-destructure into existing variables" which is more clear/correct than the prior"Can't redefine variables in tuples"

    with multi-return user functions (see #153) tuple-destructure will become much more common, and with it this language item

  8. rkalis commented on Jul 9, 2026

    @rkalis
    Member

    Now that we have multi-return values (which are internally the same type as Tuple from .split()), we should consider to do 1 (or none) of the following:

    • Allow [i] indexing of multiple return type tuples
    • Disallow [0]/[1] indexing of .split() tuples
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

    cashc-compilerRelates to the cashc compiler

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions