mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-03-16 17:00:53 +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 {
|
||||
pub fn is_unit(&self) -> bool {
|
||||
match *self {
|
||||
TypeRepr::Tuple(ref v) => v.is_empty(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn usize() -> TypeRepr {
|
||||
TypeRepr::Nominal(NominalTypeRepr {
|
||||
path: Path::usize(),
|
||||
|
@ -257,7 +257,17 @@ impl LowerState {
|
||||
{
|
||||
let action = match action {
|
||||
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`
|
||||
|
Loading…
x
Reference in New Issue
Block a user