Skip to content

forbid cast as bool + forbid surrogate chars in strings#8980

Closed
thestinger wants to merge 2 commits intorust-lang:masterfrom
thestinger:bool
Closed

forbid cast as bool + forbid surrogate chars in strings#8980
thestinger wants to merge 2 commits intorust-lang:masterfrom
thestinger:bool

Conversation

@thestinger
Copy link
Contributor

This is currently unsound since bool is represented as i8. It will
become sound when bool is stored as i8 but always used as i1.

However, the current behaviour will always be identical to x & 1 != 0,
so there's no need for it. It's also surprising, since x != 0 is the
expected behaviour.

Closes #7311

d0a1176 r=huonw
e4a76e6 r=thestinger

Copy link
Contributor

Choose a reason for hiding this comment

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

"Cannot cast to bool"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not really sure if to or as sounds nicer here, but I'm still leaning towards as.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, if someone feels strongly about it, they can come and change it later.

thestinger and others added 2 commits September 4, 2013 23:09
This is currently unsound since `bool` is represented as `i8`. It will
become sound when `bool` is stored as `i8` but always used as `i1`.

However, the current behaviour will always be identical to `x & 1 != 0`,
so there's no need for it. It's also surprising, since `x != 0` is the
expected behaviour.

Closes #7311
Reject codepoints \uD800 to \uDFFF which are the surrogates
(reserved/unused codepoints that are invalid to encode into UTF-8)

The surrogates is the only hole of invalid codepoints in the range from
\u0 to \u10FFFF.
bors added a commit that referenced this pull request Sep 5, 2013
This is currently unsound since `bool` is represented as `i8`. It will
become sound when `bool` is stored as `i8` but always used as `i1`.

However, the current behaviour will always be identical to `x & 1 != 0`,
so there's no need for it. It's also surprising, since `x != 0` is the
expected behaviour.

Closes #7311

d0a1176 r=huonw
e4a76e6 r=thestinger
@bors bors closed this Sep 5, 2013
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.

"as bool" does not properly convert its argument.

3 participants