Skip to content

Commit

Permalink
Merge pull request #458 from HigherOrderCO/top-level-names-with-doubl…
Browse files Browse the repository at this point in the history
…e-slash

Dont allow top level names start with '//'
  • Loading branch information
developedby authored May 23, 2024
2 parents 200ff15 + bf50df3 commit 5036534
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "bend-lang"
description = "A high-level, massively parallel programming language"
license = "Apache-2.0"
version = "0.2.16"
version = "0.2.17"
edition = "2021"
exclude = ["tests/snapshots/"]

Expand Down
3 changes: 3 additions & 0 deletions src/fun/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/imp/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def random//constant():
return 3.14

def //thisshouldfail():
return random//constant()

def main:
return //thisshouldfail()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
source: tests/golden_tests.rs
input_file: tests/golden_tests/compile_file/top_level_name_slashslash.bend
---
Errors:
In tests/golden_tests/compile_file/top_level_name_slashslash.bend :
Top-level names are not allowed to start with "//".
 4 | def //thisshouldfail():

0 comments on commit 5036534

Please sign in to comment.