Stop panic when typing module spam { export def-env (#6523)

* Stop `panic` when typing `module spam { export def-env`

same goes for `export extern` and `export alias`

* fmt
This commit is contained in:
pwygab 2022-09-08 17:27:11 +08:00 committed by GitHub
parent 02f92fa527
commit b398448cd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -895,7 +895,10 @@ pub fn parse_export_in_module(
let mut result = vec![]; let mut result = vec![];
let decl_name = working_set.get_span_contents(spans[2]); let decl_name = match spans.get(2) {
Some(span) => working_set.get_span_contents(*span),
None => &[],
};
let decl_name = trim_quotes(decl_name); let decl_name = trim_quotes(decl_name);
if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Any) { if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Any) {
@ -958,7 +961,10 @@ pub fn parse_export_in_module(
let mut result = vec![]; let mut result = vec![];
let decl_name = working_set.get_span_contents(spans[2]); let decl_name = match spans.get(2) {
Some(span) => working_set.get_span_contents(*span),
None => &[],
};
let decl_name = trim_quotes(decl_name); let decl_name = trim_quotes(decl_name);
if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Any) { if let Some(decl_id) = working_set.find_decl(decl_name, &Type::Any) {
@ -1021,7 +1027,10 @@ pub fn parse_export_in_module(
let mut result = vec![]; let mut result = vec![];
let alias_name = working_set.get_span_contents(spans[2]); let alias_name = match spans.get(2) {
Some(span) => working_set.get_span_contents(*span),
None => &[],
};
let alias_name = trim_quotes(alias_name); let alias_name = trim_quotes(alias_name);
if let Some(alias_id) = working_set.find_alias(alias_name) { if let Some(alias_id) = working_set.find_alias(alias_name) {