You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Malformed class instance variable member raises RuntimeError instead of RBS::ParsingError #3148
A malformed class instance variable member raises RuntimeError instead of RBS::ParsingError, so it escapes rescue RBS::ParsingError and the CLI prints a raw Ruby backtrace instead of a formatted syntax error.
require"rbs"RBS::Parser.parse_signature(RBS::Buffer.new(name: "test.rbs",content: "class M self."))
The third argument is bool syntax_error (include/rbs/parser.h:161). It is passed false, so ext/rbs_extension/main.c discards the location, token and message:
if (!error->syntax_error) {
rb_raise(rb_eRuntimeError, "Unexpected error");
}
For comparison, 49 other call sites in src/parser.c pass true and produce proper RBS::ParsingErrors.
I checked whether the other 12 false sites have the same problem, by tagging each one and fuzzing: they are defensive default: arms over already-exhausted enums and are not reachable from user input, so RuntimeError is the right semantic there. This is the only reachable one.
Environment
master cc0b38dfebd0de1f5941c1257a72e0ffc7e1c7bc. Also reproduces on released gems 4.2.0, 4.1.3, 4.0.3 and 3.10.0.
I have a patch and will open a PR referencing this issue.
Activity