This commit is contained in:
collin 2022-09-16 17:48:26 +02:00
parent 2e24f82f21
commit 62659507c5
3 changed files with 6 additions and 6 deletions

View File

@ -443,7 +443,7 @@ impl ParserContext<'_> {
let mut dist = 1; // 0th is `(` so 1st is first gc's start.
let first_gc = self.peek_group_coordinate(&mut dist)?;
let check_ahead = |d, token: &_| self.look_ahead(d, |t| (&t.token == token).then(|| t.span));
let check_ahead = |d, token: &_| self.look_ahead(d, |t| (&t.token == token).then_some(t.span));
// Peek at `,`.
check_ahead(dist, &Token::Comma)?;
@ -532,7 +532,7 @@ impl ParserContext<'_> {
let suffix_span = self.token.span;
let full_span = span + suffix_span;
let assert_no_whitespace = |x| assert_no_whitespace(span, suffix_span, &value, x);
match self.eat_any(INT_TYPES).then(|| &self.prev_token.token) {
match self.eat_any(INT_TYPES).then_some(&self.prev_token.token) {
// Literal followed by `field`, e.g., `42field`.
Some(Token::Field) => {
assert_no_whitespace("field")?;

View File

@ -262,9 +262,9 @@ impl ParserContext<'_> {
/// Returns a [`ParamMode`] AST node if the next tokens represent a function parameter mode.
pub(super) fn parse_mode(&mut self) -> Result<Mode> {
// TODO: Allow explicit "private" mode.
let public = self.eat(&Token::Public).then(|| self.prev_token.span);
let constant = self.eat(&Token::Constant).then(|| self.prev_token.span);
let const_ = self.eat(&Token::Const).then(|| self.prev_token.span);
let public = self.eat(&Token::Public).then_some(self.prev_token.span);
let constant = self.eat(&Token::Constant).then_some(self.prev_token.span);
let const_ = self.eat(&Token::Const).then_some(self.prev_token.span);
if let Some(span) = const_ {
self.emit_warning(ParserWarning::const_parameter_or_input(span));

View File

@ -51,7 +51,7 @@ impl<'a> ProgramVisitor<'a> for TypeChecker<'a> {
let check_has_field = |need, expected_ty: Type| match input
.members
.iter()
.find_map(|CircuitMember::CircuitVariable(v, t)| (v.name == need).then(|| (v, t)))
.find_map(|CircuitMember::CircuitVariable(v, t)| (v.name == need).then_some((v, t)))
{
Some((_, actual_ty)) if expected_ty.eq_flat(actual_ty) => {} // All good, found + right type!
Some((field, _)) => {