mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-04-02 08:21:03 +00:00
Synthesize default action of ()
if type is ()
This commit is contained in:
parent
487004bddb
commit
7b4a4a870c
@ -164,6 +164,13 @@ pub enum TypeRepr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TypeRepr {
|
impl TypeRepr {
|
||||||
|
pub fn is_unit(&self) -> bool {
|
||||||
|
match *self {
|
||||||
|
TypeRepr::Tuple(ref v) => v.is_empty(),
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn usize() -> TypeRepr {
|
pub fn usize() -> TypeRepr {
|
||||||
TypeRepr::Nominal(NominalTypeRepr {
|
TypeRepr::Nominal(NominalTypeRepr {
|
||||||
path: Path::usize(),
|
path: Path::usize(),
|
||||||
|
@ -257,7 +257,17 @@ impl LowerState {
|
|||||||
{
|
{
|
||||||
let action = match action {
|
let action = match action {
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
None => format!("(<>)"),
|
None => {
|
||||||
|
// If the user declared a type `()`, or we inferred
|
||||||
|
// it, then there is only one possible action that
|
||||||
|
// will type-check (`()`), so supply that. Otherwise,
|
||||||
|
// default is to include all selected items.
|
||||||
|
if nt_type.is_unit() {
|
||||||
|
format!("()")
|
||||||
|
} else {
|
||||||
|
format!("(<>)")
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Note that the action fn takes ALL of the symbols in `expr`
|
// Note that the action fn takes ALL of the symbols in `expr`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user