AlgebraicJulia / AlgebraicJulia/Catlab.jl
Error handling in `@syntax`
- Ngôn ngữ chính
- Julia
- Star
- 724
- Fork
- 73
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I just spent waay too long debugging a new syntax I made.
MWE:
```julia
@theory BiproductCategory(Ob, Hom) => Epidemiology(Ob, Hom) begin
spontaneous(A::Ob, B::Ob)::Hom(A,B)
end
@syntax FreeEpidemiology(ObExpr, HomExpr) begin
compose(f::Hom, g::Hom) = associate(new(f,g; strict=true))
end
```
Error:
```julia
LoadError: ArgumentError: invalid type for argument A in method definition for otimes at
```
This error did not point me at the problem at all. The correct syntax is:
```julia
@theory BiproductCategory(Ob, Hom) => Epidemiology(Ob, Hom) begin
spontaneous(A::Ob, B::Ob)::Hom(A,B)
end
@syntax FreeEpidemiology(ObExpr, HomExpr) Epidemiology begin
compose(f::Hom, g::Hom) = associate(new(f,g; strict=true))
end
```
I think the solution is for the macro `@syntax` to check that you gave it the name of a valid `Theory` before it continues to execute. The error should say something like `No Theory or Signature was provided to the `@syntax` macro.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.