CodeSampleX

Exemplo

equatable 2.0.8: Assert that maps of equal length with differing keys and null values are evaluated as unequal under equatable 2.0.8, correcting the false positive in 2.0.7

Amostra verificada para pub equatable 2.0.8: Assert that maps of equal length with differing keys and null values are evaluated as unequal under equatable…

sha256:535513fc87e3efcb8f9ac7d45f728474355b54e7e09b60ce585f96328ae9f8b0

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
2
Chaves de assinatura que o compilaram
2
Ambiente declarado dart linux x64 dart dart pub

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
dart 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-17
dart 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-18

Caso

HOW
Objetivo
Assert that maps of equal length with differing keys and null values are evaluated as unequal under equatable 2.0.8, correcting the false positive in 2.0.7
Pacotes
Símbolos
  • Equatable
  • mapEquals
Ambiente
dart
Criado
2026-08-17T02:07:39Z

Contrato

  1. equatable 2.0.8 evaluates maps of equal length with differing keys mapping to null values as unequal, avoiding the false positive equality in 2.0.7.

Arquivos

  • NOTES.md
  • csx.json
  • pubspec.lock
  • pubspec.yaml
  • test/contract.dart

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

NOTES.md
# Equatable Map Equality Bug (2.0.7 vs 2.0.8)

## Prior Findings
A search for existing `equatable` solutions returned:
- `sha256:bab8031169122f9dc6c2886f89021c54bf1ef9d9a669e49cd146ff4c6e003884`: Focused on generic type parameter boundaries and how `runtimeType` check prevents equality between generic instances with compatible type arguments.
- `sha256:89d2bef982143e36175a1174a40d2ddf617e91bf571cde4cd217db418fbf1a1b`: Focused on giving a class value equality with no code generation.

This sample targets a distinct behavioral fix in `mapEquals` introduced in version `2.0.8`.

## Failure Mode
In `equatable` version `2.0.7` and earlier, comparing maps of equal length with differing keys that map to null values results in a silent failure with a green build (evaluating as equal).
csx.json
{"case":{"believed":"An Equatable instance containing a Map property evaluates equality by comparing both keys and values, returning false if keys differ.","caseId":"case:sha256:e939a3a852292d3f8266f521df83620165dc48b20636b02c8b6f72f56a6a5197","contract":["equatable 2.0.8 evaluates maps of equal length with differing keys mapping to null values as unequal, avoiding the false positive equality in 2.0.7."],"goal":"Assert that maps of equal length with differing keys and null values are evaluated as unequal under equatable 2.0.8, correcting the false positive in 2.0.7","kind":"HOW","packages":["pkg:pub/equatable@2.0.8"],"schemaVersion":1,"symbols":["Equatable","mapEquals"]},"contractCommand":["dart","test/contract.dart"],"environment":{"arch":"x64","ecosystem":"pub","executionContext":"dart","language":"dart","os":"linux","packageManager":"pub","runtime":"dart","schemaVersion":1},"license":"MIT-0","packages":["pkg:pub/equatable@2.0.8"],"schemaVersion":1,"symbols":["Equatable","mapEquals"],"verifierAdapter":"pub@1"}
pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
  collection:
    dependency: transitive
    description:
      name: collection
      sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
      url: "https://pub.dev"
    source: hosted
    version: "1.19.1"
  equatable:
    dependency: "direct main"
    description:
      name: equatable
      sha256: "3e0141505477fd8ad55d6eb4e7776d3fe8430be8e497ccb1521370c3f21a3e2b"
      url: "https://pub.dev"
    source: hosted
    version: "2.0.8"
  meta:
    dependency: transitive
    description:
      name: meta
      sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9"
      url: "https://pub.dev"
    source: hosted
    version: "1.19.0"
sdks:
  dart: ">=3.5.0 <4.0.0"
pubspec.yaml
name: contract
description: A contract testing equatable mapping bug fix
version: 1.0.0
publish_to: none

environment:
  sdk: '>=3.0.0 <4.0.0'

dependencies:
  equatable: 2.0.8
test/contract.dart
import 'package:equatable/equatable.dart';

class MapHolder extends Equatable {
  final Map<String, int?> value;

  const MapHolder(this.value);

  @override
  List<Object?> get props => [value];
}

void main() {
  final map1 = {'a': 1, 'b': null};
  final map2 = {'a': 1, 'c': null};

  final holder1 = MapHolder(map1);
  final holder2 = MapHolder(map2);

  // In equatable <= 2.0.7:
  // - mapEquals evaluates map1 and map2 as equal (returning true) because:
  //   - lengths are equal (2 == 2)
  //   - key 'b' in map1 has null value
  //   - map2['b'] returns null because key 'b' doesn't exist
  //   - objectsEquals(null, null) is true, and there is no b.containsKey(key) check.
  //
  // In equatable >= 2.0.8:
  // - mapEquals correctly checks that map2 does not contain key 'b' and returns false.
  if (holder1 == holder2) {
    throw StateError(
      'Expected MapHolder($map1) and MapHolder($map2) to be unequal, '
      'but they were evaluated as equal. This is the false positive bug in equatable <= 2.0.7.'
    );
  }

  print('Success: equatable correctly evaluated the maps as unequal.');
}

Seeder de origem

csx-seed