Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assert tag #155

Merged
merged 4 commits into from
Jun 4, 2024
Merged

Add assert tag #155

merged 4 commits into from
Jun 4, 2024

Conversation

hiisuuii
Copy link
Contributor

It's fairly common in the mod dev channels to see people using asserts when they shouldn't. A quick tag to explain why they shouldn't be used and what to use instead would be beneficial.

It's fairly common in the mod dev channels to see people using asserts when they shouldn't. A quick tag to explain why they shouldn't be used and what to use instead would be beneficial.
@apple502j
Copy link
Contributor

Assertions are fine? Sure, they are meant more for debugging, but it's not that bad.

@Linguardium
Copy link

Linguardium commented Jan 26, 2024

The tag is more for letting mod devs that dont understand that it wont give the logic they want and to drive better code style with proper null checks and defaults

@altrisi
Copy link

altrisi commented Jan 26, 2024

In any case the tag is wrong given it says it'll crash if assertions are disabled (default), when they will simply be ignored.

@Linguardium
Copy link

the assertion being ignored will lead to undefined behavior, generally a NPE which will crash

@hiisuuii
Copy link
Contributor Author

hiisuuii commented Jan 27, 2024

Assertions are fine? Sure, they are meant more for debugging, but it's not that bad.

I think an important distinction to make is that assertions are fine when used correctly, which unfortunately is rarely the case when people use them in their mods. In any case, since they're disabled in the JVM by default, to achieve what the assertion did in dev, null-checking needs to be used in prod, at which point null-checking should've just been used in the first place. Oracle's stance on assertions is relevant too.

the assertion being ignored will lead to undefined behavior, generally a NPE which will crash

yeah, this is what I meant. I suppose the case is actually "when the assertion would normally fail, but assertions are disabled." I'll amend the tag.

@modmuss50 modmuss50 merged commit aedd73c into FabricMC:main Jun 4, 2024
1 check passed
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.

5 participants