-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
p2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)
Description
Describe the bug
Hi, I'm using the effect library to construct class instances, and I encounter the following issues, where the 2 assertions below pass (which is wrong):
import { Schema } from "@effect/schema";
import { Data } from "effect";
import { describe, expect, it } from "vitest";
class DataTaggedError extends Data.TaggedError("DataTaggedError")<{
msg: string;
}> {}
class SchemaTaggedError extends Schema.TaggedError<SchemaTaggedError>()(
"SchemaTaggedError",
{
msg: Schema.string,
}
) {}
describe("testing", () => {
it("debugging", () => {
//Data.TaggedError
expect({
error: new DataTaggedError({ msg: "a" }),
}).toStrictEqual({
error: new DataTaggedError({ msg: "b" }),
});
//Schema.TaggedError
expect({
error: new SchemaTaggedError({ msg: "a" }),
}).toStrictEqual({
error: new SchemaTaggedError({ msg: "b" }),
});
});
});I've initially raised an issue on the effect, but it result that by comparing with the native assert it works as expected:
import { Schema } from "@effect/schema";
import { Data } from "effect";
import * as assert from "node:assert";
class SchemaTaggedError extends Schema.TaggedError<SchemaTaggedError>()(
"SchemaTaggedError",
{
msg: Schema.string,
}
) {}
class DataTaggedError extends Data.TaggedError("DataTaggedError")<{
msg: string;
}> {}
// no error
assert.deepStrictEqual(
{ error: new DataTaggedError({ msg: "a" }) },
{ error: new DataTaggedError({ msg: "a" }) }
);
// error report properly
assert.deepStrictEqual(
{ error: new DataTaggedError({ msg: "a" }) },
{ error: new DataTaggedError({ msg: "b" }) }
);
// no error
assert.deepStrictEqual(
{ error: new SchemaTaggedError({ msg: "a" }) },
{ error: new SchemaTaggedError({ msg: "a" }) }
);
// error report properly
assert.deepStrictEqual(
{ error: new SchemaTaggedError({ msg: "a" }) },
{ error: new SchemaTaggedError({ msg: "b" }) }
);Reproduction
reproduction on StackBlitz with the code above
System Info
System:
OS: macOS 12.2.1
CPU: (8) arm64 Apple M1 Pro
Memory: 476.78 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 20.3.0 - ~/.volta/tools/image/node/20.3.0/bin/node
Yarn: 1.22.19 - ~/.volta/bin/yarn
npm: 9.6.7 - ~/.volta/tools/image/node/20.3.0/bin/npm
pnpm: 8.3.1 - ~/.volta/bin/pnpm
Browsers:
Chrome: 121.0.6167.184
Safari: 15.3
npmPackages:
vitest: ^1.2.2 => 1.2.2Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
p2-nice-to-haveNot breaking anything but nice to have (priority)Not breaking anything but nice to have (priority)