mirror of
https://github.com/HigherOrderCO/Bend.git
synced 2024-09-11 11:56:54 +03:00
Dont allow top level names start with '//'
This commit is contained in:
parent
200ff1558f
commit
af8d6e3e0b
@ -812,6 +812,9 @@ pub trait ParserCommons<'a>: Parser<'a> {
|
||||
if nam.contains("__") {
|
||||
let msg = "Top-level names are not allowed to contain \"__\".".to_string();
|
||||
self.with_ctx(Err(msg), ini_idx, end_idx)
|
||||
} else if nam.starts_with("//") {
|
||||
let msg = "Top-level names are not allowed to start with \"//\".".to_string();
|
||||
self.with_ctx(Err(msg), ini_idx, end_idx)
|
||||
} else {
|
||||
Ok(nam)
|
||||
}
|
||||
|
@ -912,7 +912,7 @@ impl<'a> PyParser<'a> {
|
||||
}
|
||||
|
||||
self.skip_trivia_inline();
|
||||
let name = self.parse_bend_name()?;
|
||||
let name = self.parse_top_level_name()?;
|
||||
self.skip_trivia_inline();
|
||||
let params = if self.starts_with("(") {
|
||||
self.list_like(|p| p.parse_bend_name(), "(", ")", ",", true, 0)?
|
||||
|
@ -0,0 +1,8 @@
|
||||
def random//constant():
|
||||
return 3.14
|
||||
|
||||
def //thisshouldfail():
|
||||
return random//constant()
|
||||
|
||||
def main:
|
||||
return //thisshouldfail()
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
source: tests/golden_tests.rs
|
||||
input_file: tests/golden_tests/compile_file/top_level_name_slashslash.bend
|
||||
---
|
||||
[4m[1m[31mErrors:[0m
|
||||
In tests/golden_tests/compile_file/top_level_name_slashslash.bend :
|
||||
Top-level names are not allowed to start with "//".
|
||||
[0m 4 | def [4m[31m//thisshouldfail[0m():[0m
|
Loading…
Reference in New Issue
Block a user