-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Summary
The mbti_parser does not support several visibility-prefixed constructs that are used in official MoonBit toolchain-generated .mbti files.
Affected Patterns
1. pub impl
pub impl ToJson for FooterColumn
pub impl Add for BigInt
2. pub using
pub using @builtin {type ArrayView as View}
3. pub let
pub let null : Json
pub let max_value : Byte
Evidence
These patterns are present in the official MoonBit core library's .mbti files:
$ grep -r "^pub impl" ~/.moon/lib/core/**/*.mbti | head -3
/Users/.../.moon/lib/core/bench/pkg.generated.mbti:pub impl ToJson for Summary
/Users/.../.moon/lib/core/bigint/pkg.generated.mbti:pub impl Add for BigInt
...
$ grep -r "^pub using" ~/.moon/lib/core/**/*.mbti | head -3
/Users/.../.moon/lib/core/array/pkg.generated.mbti:pub using @builtin {type ArrayView as View}
...
$ grep -r "^pub let" ~/.moon/lib/core/**/*.mbti | head -3
/Users/.../.moon/lib/core/builtin/pkg.generated.mbti:pub let null : Json
...Root Cause
Looking at mbti_parser/mbti_parser.mbty:
impl_sig (line 188-192)
impl_sig -> ImplSig
: "impl" type_params_with_constraints qualified_uident "for" type_ { ... }
| "impl" qualified_uident "for" type_ { ... }
| "impl" uident "::" lident { ... }
;
The impl_sig rule starts directly with the "impl" keyword and does not accept a vis (visibility) prefix like type_sig or trait_sig do.
Missing using support
There is no grammar rule for using statements in the mbti parser.
value_sig (line 150-152)
value_sig -> ValueSig
: attributes "let" lident ":" type_ { ... }
;
The value_sig rule does not accept a vis prefix.
Expected Behavior
Per CONTRIBUTING.md:
This project aims to follow the behavior of MoonBit's OCaml parser implementation when the input source has no syntax errors.
These patterns should be parseable since they are generated by the official MoonBit toolchain.
Suggested Fix
- Add
visprefix support toimpl_sig - Add
usingstatement grammar rule - Add
visprefix support tovalue_sig
Metadata
Metadata
Assignees
Labels
No labels