effect icon indicating copy to clipboard operation
effect copied to clipboard

Class APIs: overriding a field is allowed but looks unsafe

Open gcanti opened this issue 1 year ago • 0 comments

What version of Effect is running?

@effect/schema 0.63.1

What steps can reproduce the bug?

import * as ParseResult from "@effect/schema/ParseResult"
import * as S from "@effect/schema/Schema"

class A extends S.Class<A>()({ a: S.string }) {
  trim() {
    return this.a.trim()
  }
}

class B extends A.extend<B>()({ a: S.number }) {}

new B({ a: 1 }).trim() // BOOM!

class C extends A.transformOrFail<C>()(
  { a: S.number },
  () => ParseResult.succeed({ a: 1 }),
  () => ParseResult.succeed({ a: "a" })
) {}

new C({ a: 1 }).trim() // BOOM!

class D extends A.transformOrFailFrom<D>()(
  { a: S.number },
  () => ParseResult.succeed({ a: 1 }),
  () => ParseResult.succeed({ a: "a" })
) {}

new D({ a: 1 }).trim() // BOOM!

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

/cc @tim-smart

gcanti avatar Feb 29 '24 19:02 gcanti