Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crates/ts_goport/data/effect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Effect diagnostics reference data

`effectDiagnosticMessages.json` is copied unchanged from
[Effect-TS/tsgo](https://github.com/Effect-TS/tsgo) at the `@effect/tsgo@0.46.1`
release commit `f1a7cad0292d9d315e7f87694f127f605711d55e`
(`internal/diagnostics/effectDiagnosticMessages.json`).

`scripts/effect/gen-effect-messages.mjs` turns it into
`crates/ts_goport/src/diagnostics/effect_catalog.rs` (the messages) and
`crates/ts_goport/src/effect/diag.rs` (their Go names). Run it again after a
change to the JSON.
534 changes: 534 additions & 0 deletions crates/ts_goport/data/effect/effectDiagnosticMessages.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions crates/ts_goport/src/checker/checker_p01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,14 @@ pub struct Checker {
/// Go `tracer *Tracer` (checker.go:897): optional tracer for trace
/// events and type recording (for --generateTrace). None is Go nil.
pub tracer: Option<crate::tracing::Tracer>,

/// Effect-TS/tsgo patch 023 `EffectLinks`: the Effect type parser caches
/// (`effect::typeparser`). None until a rule first runs.
pub effect_links: Option<Box<crate::effect::typeparser::EffectLinks>>,
/// Effect-TS/tsgo patches 002 and 004 `SourceFileLinks.relationErrors`:
/// the relation errors of each source file, for Effect rules. Kept only
/// when the program has Effect diagnostics options.
pub effect_relation_errors: FxHashMap<Node, Vec<crate::effect::RelationError>>,
}

// Arena accessors (PORTING.md "Checker data"). Handles index their arena
Expand Down Expand Up @@ -1637,6 +1645,8 @@ impl Checker {
// Go: compiler/checkerpool.go:104 makes the tracer when the pool
// has a tracing session; NewChecker stores it (checker.go:905).
tracer: crate::tracing::new_checker_tracer(checker_index),
effect_links: None,
effect_relation_errors: FxHashMap::default(),
};
// Closure optimization
c.compare_symbols = Rc::new(|c: &mut Checker, s1: SymbolId, s2: SymbolId| -> i32 {
Expand Down
5 changes: 5 additions & 0 deletions crates/ts_goport/src/checker/checker_p03.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ impl Checker {
true,
)
});
// Effect-TS/tsgo patch 002: clear any stale relation errors before type checking.
self.effect_relation_errors.remove(&source_file);
// Grammar checking
self.check_grammar_source_file(source_file);
self.renamed_binding_elements_in_types = Vec::new();
Expand All @@ -256,6 +258,9 @@ impl Checker {
self.produce_deferred_diagnostics();
self.reported_unreachable_nodes.clear();
self.source_file_links.get(source_file).type_checked = true;

// Effect-TS/tsgo patch 002: run Effect diagnostics after type checking.
crate::effect::after_check_source_file(ctx, self, source_file);
}
if check_unused && !self.source_file_links.get(source_file).unused_checked {
// The unused identifiers check relies on a full type check having first been performed
Expand Down
16 changes: 16 additions & 0 deletions crates/ts_goport/src/checker/relater_p5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,6 +1778,22 @@ impl Checker {
source: TypeId,
target: TypeId,
) {
// Effect-TS/tsgo patch 004: collect the relation error for Effect diagnostics.
if self.compiler_options.effect.is_some() {
let error_node = r.borrow().error_node;
if error_node.is_some() {
let sf = get_source_file_of_node(error_node);
if sf.is_some() {
self.effect_relation_errors.entry(sf).or_default().push(
crate::effect::RelationError {
source,
target,
error_node,
},
);
}
}
}
let (source_type, target_type) = self.get_type_names_for_error_display(source, target);
let mut generalized_source = source;
let mut generalized_source_type = source_type.clone();
Expand Down
Loading