Skip to content

Commit

Permalink
Support suppressing issues on definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 22, 2024
1 parent 7659ded commit 478ccce
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/analyzer/file_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a> FileAnalyzer<'a> {
let statements_analyzer = StatementsAnalyzer::new(
&unnamespaced_file_analyzer,
&type_resolution_context,
Vec::new(),
Vec::from_iter(self.file_source.comments.iter()),
);

let mut context = ScopeContext::new(FunctionContext::new());
Expand Down
2 changes: 2 additions & 0 deletions tests/inference/Enum/duplicateEnumValue/input.hack
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ enum Suit: string {
Diamonds = "d";
Clubs = "c";
Spades = "c";
/* HAKANA_FIXME[DuplicateEnumValue] */
Aces = "c";
}

enum Color: int {
Expand Down
2 changes: 1 addition & 1 deletion tests/inference/Enum/duplicateEnumValue/output.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ERROR: DuplicateEnumValue - input.hack:5:14 - Duplicate enum value for Suit, previously defined by case Clubs
ERROR: DuplicateEnumValue - input.hack:12:14 - Duplicate enum value for Color, previously defined by case Blue
ERROR: DuplicateEnumValue - input.hack:14:14 - Duplicate enum value for Color, previously defined by case Blue
26 changes: 26 additions & 0 deletions tests/inference/Immutable/writeImmutableDefinedOnTrait/input.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<<Hakana\Immutable>>
trait T {
public int $b;
public function __construct(int $b) {
$this->b = $b; // ok
}
}

class A {
use T;

public function mutate() {
$this->b = 5; // gets flagged
}
}

<<__EntryPoint>>
function main() {
$a = new A(3);
$a->b = 6; // ok
bar($a);
}

function bar(A $a): void {
$a->b = 7; // gets flagged
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ERROR: ImmutablePropertyWrite - input.hack:13:16 - Property A::$b is defined on an immutable class
ERROR: ImmutablePropertyWrite - input.hack:25:9 - Property A::$b is defined on an immutable class

0 comments on commit 478ccce

Please sign in to comment.