Remove other references to private tags in code

This commit is contained in:
Ayaz Hafiz 2022-04-25 11:50:00 -04:00
parent 2ab01107d3
commit 55706ae5c4
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
8 changed files with 32 additions and 99 deletions

View file

@ -70,10 +70,9 @@ xor : Bool, Bool -> Bool
## Structural equality works as follows:
##
## 1. Global tags are equal if they are the same tag, and also their contents (if any) are equal.
## 2. Private tags are equal if they are the same tag, in the same module, and also their contents (if any) are equal.
## 3. Records are equal if all their fields are equal.
## 4. Collections ([Str], [List], [Dict], and [Set]) are equal if they are the same length, and also all their corresponding elements are equal.
## 5. [Num] values are equal if their numbers are equal, with one exception: if both arguments to `isEq` are *NaN*, then `isEq` returns `False`. See `Num.isNaN` for more about *NaN*.
## 2. Records are equal if all their fields are equal.
## 3. Collections ([Str], [List], [Dict], and [Set]) are equal if they are the same length, and also all their corresponding elements are equal.
## 4. [Num] values are equal if their numbers are equal, with one exception: if both arguments to `isEq` are *NaN*, then `isEq` returns `False`. See `Num.isNaN` for more about *NaN*.
##
## Note that `isEq` takes `'val` instead of `val`, which means `isEq` does not
## accept arguments whose types contain functions.

View file

@ -7,7 +7,7 @@ use roc_region::all::{Loc, Region};
/// The canonicalization environment for a particular module.
pub struct Env<'a> {
/// The module's path. Private tags and unqualified references to identifiers
/// The module's path. Opaques and unqualified references to identifiers
/// are assumed to be relative to this path.
pub home: ModuleId,

View file

@ -1,7 +1,5 @@
use crate::docs::DocEntry::DetachedDoc;
use crate::docs::TypeAnnotation::{
Apply, BoundVariable, Function, NoTypeAnn, ObscuredRecord, ObscuredTagUnion, Record, TagUnion,
};
use crate::docs::TypeAnnotation::{Apply, BoundVariable, Function, NoTypeAnn, Record, TagUnion};
use crate::file::LoadedModule;
use roc_can::scope::Scope;
use roc_error_macros::todo_abilities;
@ -274,27 +272,12 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
ast::TypeAnnotation::TagUnion { tags, ext } => {
let mut tags_to_render: Vec<Tag> = Vec::new();
let mut any_tags_are_private = false;
for tag in tags.iter() {
match tag_to_doc(in_func_type_ann, tag.value) {
None => {
any_tags_are_private = true;
break;
}
Some(tag_ann) => {
if let Some(tag_ann) = tag_to_doc(in_func_type_ann, tag.value) {
tags_to_render.push(tag_ann);
}
}
}
if any_tags_are_private {
if in_func_type_ann {
ObscuredTagUnion
} else {
NoTypeAnn
}
} else {
let extension = match ext {
None => NoTypeAnn,
Some(ext_type_ann) => type_to_docs(in_func_type_ann, ext_type_ann.value),
@ -305,7 +288,6 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
extension: Box::new(extension),
}
}
}
ast::TypeAnnotation::BoundVariable(var_name) => BoundVariable(var_name.to_string()),
ast::TypeAnnotation::Apply(module_name, type_name, type_ann_parts) => {
let mut name = String::new();
@ -328,26 +310,11 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
ast::TypeAnnotation::Record { fields, ext } => {
let mut doc_fields = Vec::new();
let mut any_fields_include_private_tags = false;
for field in fields.items {
match record_field_to_doc(in_func_type_ann, field.value) {
None => {
any_fields_include_private_tags = true;
break;
}
Some(doc_field) => {
if let Some(doc_field) = record_field_to_doc(in_func_type_ann, field.value) {
doc_fields.push(doc_field);
}
}
}
if any_fields_include_private_tags {
if in_func_type_ann {
ObscuredRecord
} else {
NoTypeAnn
}
} else {
let extension = match ext {
None => NoTypeAnn,
Some(ext_type_ann) => type_to_docs(in_func_type_ann, ext_type_ann.value),
@ -358,7 +325,6 @@ fn type_to_docs(in_func_type_ann: bool, type_annotation: ast::TypeAnnotation) ->
extension: Box::new(extension),
}
}
}
ast::TypeAnnotation::SpaceBefore(&sub_type_ann, _) => {
type_to_docs(in_func_type_ann, sub_type_ann)
}

View file

@ -392,7 +392,7 @@ pub struct Subs {
pub struct TagNameCache {
globals: Vec<Uppercase>,
globals_slices: Vec<SubsSlice<TagName>>,
/// Currently private tags and closure tags; in the future just closure tags
/// Just closure tags
symbols: Vec<Symbol>,
symbols_slices: Vec<SubsSlice<TagName>>,
}

View file

@ -70,8 +70,6 @@ pub enum Token {
Malformed,
MalformedOperator,
PrivateTag,
String,
NumberBase,
@ -149,7 +147,6 @@ fn consume_all_tokens(state: &mut LexState, bytes: &[u8], consumer: &mut impl Co
b']' => (Token::CloseSquare, 1),
b',' => (Token::Comma, 1),
b'_' => lex_underscore(bytes),
b'@' => lex_private_tag(bytes),
b'a'..=b'z' => lex_ident(false, bytes),
b'A'..=b'Z' => lex_ident(true, bytes),
b'0'..=b'9' => lex_number(bytes),
@ -408,15 +405,6 @@ fn is_ident_continue(ch: u8) -> bool {
matches!(ch, b'a'..=b'z'|b'A'..=b'Z'|b'0'..=b'9'|b'_')
}
fn lex_private_tag(bytes: &[u8]) -> (Token, usize) {
debug_assert!(bytes[0] == b'@');
let mut i = 1;
while i < bytes.len() && is_ident_continue(bytes[i]) {
i += 1;
}
(Token::PrivateTag, i)
}
fn lex_ident(uppercase: bool, bytes: &[u8]) -> (Token, usize) {
let mut i = 0;
while i < bytes.len() && is_ident_continue(bytes[i]) {

View file

@ -72,10 +72,7 @@ mod test_peg_grammar {
rule tag() =
private_tag()
/ [T::UppercaseIdent]
rule private_tag() = [T::PrivateTag] {}
[T::UppercaseIdent]
rule list() = empty_list()

View file

@ -1253,9 +1253,9 @@ fn pretty_runtime_error<'b>(
EmptySingleQuote | MultipleCharsInSingleQuote | Unknown | BadIdent(_) => {
alloc.nil()
}
QualifiedIdentifier => alloc.tip().append(
alloc.reflow("In patterns, only private and global tags can be qualified"),
),
QualifiedIdentifier => alloc
.tip()
.append(alloc.reflow("In patterns, only global tags can be qualified")),
};
doc = alloc.stack([

View file

@ -417,21 +417,6 @@ impl<'a> RocDocAllocator<'a> {
.annotate(Annotation::Symbol)
}
pub fn private_tag_name(&'a self, symbol: Symbol) -> DocBuilder<'a, Self, Annotation> {
if symbol.module_id() == self.home {
// Render it unqualified if it's in the current module.
self.text(format!("{}", symbol.ident_str(self.interns)))
.annotate(Annotation::PrivateTag)
} else {
self.text(format!(
"{}.{}",
symbol.module_string(self.interns),
symbol.ident_str(self.interns),
))
.annotate(Annotation::PrivateTag)
}
}
pub fn global_tag_name(&'a self, uppercase: Uppercase) -> DocBuilder<'a, Self, Annotation> {
self.text(format!("{}", uppercase))
.annotate(Annotation::GlobalTag)
@ -807,7 +792,6 @@ pub enum Annotation {
Url,
Keyword,
GlobalTag,
PrivateTag,
RecordField,
TypeVariable,
Alias,
@ -899,8 +883,7 @@ where
Url => {
self.write_str("<")?;
}
GlobalTag | PrivateTag | Keyword | RecordField | Symbol | Typo | TypoSuggestion
| TypeVariable
GlobalTag | Keyword | RecordField | Symbol | Typo | TypoSuggestion | TypeVariable
if !self.in_type_block && !self.in_code_block =>
{
self.write_str("`")?;
@ -930,7 +913,7 @@ where
Url => {
self.write_str(">")?;
}
GlobalTag | PrivateTag | Keyword | RecordField | Symbol | Typo | TypoSuggestion
GlobalTag | Keyword | RecordField | Symbol | Typo | TypoSuggestion
| TypeVariable
if !self.in_type_block && !self.in_code_block =>
{
@ -1023,7 +1006,7 @@ where
ParserSuggestion => {
self.write_str(self.palette.parser_suggestion)?;
}
TypeBlock | GlobalTag | PrivateTag | RecordField => { /* nothing yet */ }
TypeBlock | GlobalTag | RecordField => { /* nothing yet */ }
}
self.style_stack.push(*annotation);
Ok(())
@ -1041,7 +1024,7 @@ where
self.write_str(self.palette.reset)?;
}
TypeBlock | GlobalTag | PrivateTag | Opaque | RecordField => { /* nothing yet */ }
TypeBlock | GlobalTag | Opaque | RecordField => { /* nothing yet */ }
},
}
Ok(())