Skip to content

Example code on homepage does not compile #1072

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

Open
xwu opened this issue Jun 8, 2025 · 0 comments
Open

Example code on homepage does not compile #1072

xwu opened this issue Jun 8, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@xwu
Copy link
Contributor

xwu commented Jun 8, 2025

Describe the bug

A number of examples on the main site do not compile. Some appear to lack necessary import statements; others do not work in the currently released version of Swift.

The first example, under "Fast," crashes the compiler for at least one user, and produces the following compiler diagnostics for me in the REPL:

                        ˄˜˜˜     ˄
                        │        ╰─ error: generic parameter 'Scalar' could not be inferred
                        │        ╰─ note: explicitly specify the generic arguments to fix this issue
                        ╰─ error: cannot find type 'Span' in scope

To Reproduce

Steps to reproduce the behavior:

  1. Go to swift.org
  2. Scroll down to 'Fast'
  3. Copy code and paste into Swift REPL
  4. Observe compiler error

Expected behavior

Code should compile successfully.

Actual behavior

Code does not compile successfully.

Environment details

Desktop (please complete the following information):

  • OS: macOS Sequoia 15.5
  • Apple Swift version 6.1 (swift-6.1-RELEASE)

If possible, minimal yet complete reproducer code (or link to code)

// Vectorized check that a utf8 buffer is all ASCII
func isASCII(utf8: Span<SIMD16<UInt8>>) -> Bool {
  // combine all the code units into a single entry
  utf8.indices.reduce(into: SIMD16()) {
    // fold each set of code units into the result
    $0 |= utf8[$1]
  }
  // check that every entry is in the ASCII range
  .max() < 0x80
}

Swift.org version/commit hash

(?)

Additional context

@xwu xwu added the bug Something isn't working label Jun 8, 2025
@xwu xwu changed the title Example code does not compile Example code on homepage does not compile Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant