mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Disallow any keyword followed by an exclaimation mark
This commit is contained in:
parent
0acd59b4d6
commit
9e6c249dca
13 changed files with 23 additions and 83 deletions
|
@ -1,4 +1,5 @@
|
|||
use crate::ast::TryTarget;
|
||||
use crate::keyword::is_allowed_identifier;
|
||||
use crate::parser::Progress::{self, *};
|
||||
use crate::parser::{BadInputError, EExpr, ParseResult, Parser};
|
||||
use crate::state::State;
|
||||
|
@ -60,7 +61,7 @@ pub fn lowercase_ident<'a>() -> impl Parser<'a, &'a str, ()> {
|
|||
move |_, state: State<'a>, _min_indent: u32| match chomp_lowercase_part(state.bytes()) {
|
||||
Err(progress) => Err((progress, ())),
|
||||
Ok(ident) => {
|
||||
if crate::keyword::KEYWORDS.iter().any(|kw| &ident == kw) {
|
||||
if !is_allowed_identifier(&ident) {
|
||||
Err((NoProgress, ()))
|
||||
} else {
|
||||
let width = ident.len();
|
||||
|
@ -87,7 +88,7 @@ pub fn lowercase_ident_keyword_e<'a>() -> impl Parser<'a, &'a str, ()> {
|
|||
move |_, state: State<'a>, _min_indent: u32| match chomp_lowercase_part(state.bytes()) {
|
||||
Err(progress) => Err((progress, ())),
|
||||
Ok(ident) => {
|
||||
if crate::keyword::KEYWORDS.iter().any(|kw| &ident == kw) {
|
||||
if !is_allowed_identifier(&ident) {
|
||||
Err((MadeProgress, ()))
|
||||
} else {
|
||||
let width = ident.len();
|
||||
|
@ -137,7 +138,7 @@ pub fn unqualified_ident<'a>() -> impl Parser<'a, &'a str, ()> {
|
|||
move |_, state: State<'a>, _min_indent: u32| match chomp_anycase_part(state.bytes()) {
|
||||
Err(progress) => Err((progress, ())),
|
||||
Ok(ident) => {
|
||||
if crate::keyword::KEYWORDS.iter().any(|kw| &ident == kw) {
|
||||
if !is_allowed_identifier(&ident) {
|
||||
Err((MadeProgress, ()))
|
||||
} else {
|
||||
let width = ident.len();
|
||||
|
@ -166,8 +167,8 @@ pub fn parse_ident<'a>(
|
|||
if let Ident::Access { module_name, parts } = ident {
|
||||
if module_name.is_empty() {
|
||||
if let Some(first) = parts.first() {
|
||||
for keyword in crate::keyword::KEYWORDS.iter() {
|
||||
if first == &Accessor::RecordField(keyword) {
|
||||
if let Accessor::RecordField(ident) = first {
|
||||
if !is_allowed_identifier(ident) {
|
||||
return Err((NoProgress, EExpr::Start(initial.pos())));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue