Skip to content

Produce error for duplicate object names - #50

Merged
Imberflur merged 1 commit into
misc-improvements-docs-testsfrom
duplicate-objects-error
Oct 23, 2025
Merged

Produce error for duplicate object names#50
Imberflur merged 1 commit into
misc-improvements-docs-testsfrom
duplicate-objects-error

Conversation

@Imberflur

Copy link
Copy Markdown
Contributor

Can be merged after #49

Previously the value from the last defined object was used. Now we produce an error.

Error: Parser error
   ╭─[ a:2:1 ]
   │
 2 │ test = integration::Test{ x: -5, y: 4 }
   │ ──┬─
   │   ╰─── This identifier was already used
───╯

@hazelwiss hazelwiss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some minor notes.

match ty {
ItemType::Value => {
if values.values.contains_key(&ident) {
emitter.emit(Rich::custom(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if emitter is emitted from then, what, it will result in an error? Seems like it I think but it is not super clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

}

#[test]
#[should_panic]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how we feel about should panic tests where we do not more clearly specify the output of the panic, given well it could potentially panic for unrelated reasons? I suppose we hope that those panics are caught by other tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to have them than to not have them at least.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we need to move the error messages into the panic message to be able to test the specific output. Alternatively, we could try to have tests that don't panic on errors but instead check them for certain content. We could open an issue for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#59

@Imberflur
Imberflur merged commit dda27a9 into misc-improvements-docs-tests Oct 23, 2025
Imberflur added a commit that referenced this pull request Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants