mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
fix: overload resolution bug
This commit is contained in:
parent
66352ddd3a
commit
21d5f22ca8
5 changed files with 30 additions and 1 deletions
|
@ -1126,7 +1126,15 @@ impl Context {
|
|||
_ => {}
|
||||
}
|
||||
if self.subtype_of(ty, &input_t) {
|
||||
return Ok(ty.clone());
|
||||
if let Ok(instance) = self.instantiate(ty.clone(), obj) {
|
||||
let subst = self
|
||||
.substitute_call(obj, &None, &instance, pos_args, kw_args, self)
|
||||
.is_ok();
|
||||
let eval = self.eval_t_params(instance, self.level, obj).is_ok();
|
||||
if subst && eval {
|
||||
return Ok(ty.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let Type::Subr(subr_t) = input_t else {
|
||||
|
|
4
crates/erg_compiler/lib/external/matplotlib.d/image.d.er
vendored
Normal file
4
crates/erg_compiler/lib/external/matplotlib.d/image.d.er
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
_ImageBase: ClassType
|
||||
|
||||
.AxesImage!: ClassType
|
||||
.AxesImage! <: _ImageBase
|
|
@ -6,9 +6,12 @@ legend = pyimport "../legend"
|
|||
.style = pyimport "../style"
|
||||
figure = pyimport "../figure"
|
||||
axes = pyimport "../axes"
|
||||
image = pyimport "../image"
|
||||
|
||||
.plot!: (*args: Obj, scaleX := Bool, scaleY := Bool) => [Obj; _]
|
||||
.imshow!: (X: Obj, cmap := Str, interpolation := Str) => image.AxesImage!
|
||||
.show!: () => NoneType
|
||||
.text!: (x: Float, y: Float, s: Str, fontdict := {Str: Obj}, fontsize := Nat) => text.Text
|
||||
.title!: (title: Str) => text.Text
|
||||
.xlabel!: (label: Str) => text.Text
|
||||
.ylabel!: (label: Str) => text.Text
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
np = pyimport "numpy"
|
||||
|
||||
.backends = pyimport "./backends"
|
||||
.cuda = pyimport "./cuda"
|
||||
.nn = pyimport "./nn"
|
||||
|
@ -33,9 +35,17 @@
|
|||
.Tensor!(T, S)|<: IrregularEq|.
|
||||
Output: {Tensor!(Bool, S)}
|
||||
__eq__: (self: .Tensor!(T, S), other: .Tensor!(T, S)) -> .Tensor!(Bool, S)
|
||||
.Tensor!(T, S)|<: Indexable(Nat, .Tensor!(T, _))|.
|
||||
__getitem__: (self: .Tensor!(T, S), index: Nat or [Nat; _]) -> .Tensor!(T, _)
|
||||
.Tensor!(T, S).
|
||||
data: .Tensor!(T, S)
|
||||
.Tensor!(_, _).
|
||||
dtype: .DType
|
||||
shape: .Size
|
||||
clone: |T, S: [Nat; _]|(self: .Tensor!(T, S)) -> .Tensor!(T, S)
|
||||
cpu: |T, S: [Nat; _]|(self: .Tensor!(T, S)) -> .Tensor!(T, S)
|
||||
detach: |T, S: [Nat; _]|(self: .Tensor!(T, S)) -> .Tensor!(T, S)
|
||||
numpy: |T, S: [Nat; _]|(self: .Tensor!(T, S)) -> np.NDArray(T, S)
|
||||
view: (|T, Old: [Nat; _], S: {A: [Nat; _] | A.prod() == Old.prod()}|(
|
||||
self: .Tensor!(T, Old),
|
||||
shape: {S},
|
||||
|
@ -64,6 +74,7 @@
|
|||
and (|T|(self: .Tensor!(T, _), dim: Nat) -> .Tensor!(T, _))
|
||||
|
||||
.relu: |T, S: [Nat; _]|(x: .Tensor!(T, S)) -> .Tensor!(T, S)
|
||||
.softmax: |T, S: [Nat; _]|(x: .Tensor!(T, S), dim: Nat) -> .Tensor!(T, S)
|
||||
.max: (|T|(input: .Tensor!(T, _), dim: Nat, keepdim := Bool) -> (.Tensor!(T, _)), .Tensor!(T, _)) \
|
||||
and (|T|(input: .Tensor!(T, _)) -> .Tensor!(T, _))
|
||||
.min: (|T|(input: .Tensor!(T, _), dim: Nat, keepdim := Bool) -> (.Tensor!(T, _)), .Tensor!(T, _)) \
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
dataset = pyimport "torch/utils/data/dataset"
|
||||
{Tensor!;} = pyimport "torch"
|
||||
|
||||
.VisionDataset: ClassType
|
||||
.VisionDataset <: dataset.Dataset
|
||||
.VisionDataset|<: Indexable(Nat, (Tensor!(Float, _), Tensor!(Float, _)))|.
|
||||
__getitem__: (index: Nat) -> (Tensor!(Float, _), Tensor!(Float, _))
|
||||
.VisionDataset.
|
||||
__call__: (
|
||||
root: Str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue