AlgebraicJulia / AlgebraicJulia/Catlab.jl

Error handling in `@syntax`

Aberta
#135 2 comentários 0 reações 0 responsáveis Ver no GitHub
bug GATs
Linguagem predominante
Julia
Estrelas
724
Forks
73
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.