icerpc / slicec

The Slice compiler library
Apache License 2.0
13 stars 5 forks source link

Doc Comment `throws` can't link to Exceptions in other Modules #661

Closed InsertCreativityHere closed 11 months ago

InsertCreativityHere commented 11 months ago

Currently the throws tag only accepts unscoped identifiers, there is no way to do:

interface MyInterface {
    /// @throws ::Test2::MyException: when it breaks
    op() throws ::Test2::MyException
}

instead the parser expects this:

interface MyInterface {
    /// @throws MyException: when it breaks
    op() throws ::Test2::MyException
}

Both could work in theory.

1) If we allow scoped identifiers, then the parser can resolve the link using that scoped identifier.

2) But even if we keep the current behavior (only unscoped identifier), we can still find the exception in the exception specification and link against that. We already check to ensure that anything in an @throws tag matches up with a specified exception.

Option 2 seems more convenient, but is more 'magical' than the option 1.

bernardnormier commented 11 months ago

I don't see how Option 2 could work. For example, the following is valid Slice:

op() throws (::M1::MyException, ::M2::MyException)

Which MyException does an unqualified "@throws MyException" refer to?

InsertCreativityHere commented 11 months ago

Yes you're right, option 2 is unworkable. Option 1 is the only sane choice.