Skip to content

Fix array validation, length calculation, and compiler diagnostics - #205

Merged
someone235 merged 1 commit into
kaspanet:masterfrom
someone235:fixes
Aug 7, 2026
Merged

Fix array validation, length calculation, and compiler diagnostics#205
someone235 merged 1 commit into
kaspanet:masterfrom
someone235:fixes

Conversation

@someone235

@someone235 someone235 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This PR fixes several compiler correctness issues involving array encoding, comparisons, and ambiguous declarations.

Bug Fixes

  • Reject malformed dynamic-array entrypoint payloads whose encoded length is not divisible by the element width.

  • Correct .length for derived arrays so it returns the element count instead of the encoded byte count.

// Correctly evaluates to 1 rather than 8.
require(values.slice(0, 1).length == 1);
  • Validate fixed-array casts using total encoded size. Equal-size reinterpretations remain valid, while casts that would produce an invalid representation are rejected.
byte[16] bytes = byte[16](int[2]{1, 2}); // Valid
byte[2] bytes = byte[2](int[2]{1, 2});   // Rejected
  • Reject ordered comparisons on non-numeric values before they produce invalid numeric operations at runtime. Equality and inequality remain supported.
require("a" < "b");   // Rejected
require("a" == "a");  // Valid
  • Report a compiler error when an entrypoint parameter conflicts with a contract field instead of panicking internally.

  • Reject duplicate entrypoint and helper-function names instead of silently resolving them inconsistently.

@someone235 someone235 changed the title Some fixes Fix array validation, length calculation, and compiler diagnostics Aug 7, 2026
@someone235
someone235 merged commit cb34aa5 into kaspanet:master Aug 7, 2026
4 checks passed
@someone235
someone235 deleted the fixes branch August 7, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant