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

regexp: a bare ? should be treated as an error #1428

Closed
gopherbot opened this issue Jan 18, 2011 · 2 comments
Closed

regexp: a bare ? should be treated as an error #1428

gopherbot opened this issue Jan 18, 2011 · 2 comments

Comments

@gopherbot
Copy link

by benlynn:

This program (attached):

package main
import "regexp"
func main() {
  f := func(pattern, s string) {
    switch b, err := regexp.Match(pattern, []byte(s)); err {
    case nil: { println("Got a match?", b) }
    default:  { println("FAIL:", err.String()) }
    }
  }
  f("a+b", "a+b")
  f("a*b", "a*b")
  f("a?b", "a?b")
  f("+b", "+b")
  f("*b", "*b")
  f("?b", "?b")
}

outputs this:

  Got a match? false
  Got a match? true
  Got a match? true
  FAIL: closure applies to nothing
  FAIL: closure applies to nothing
  Got a match? true

but the last case should also trigger an error.

The fix is obvious and trivial. I'll post a CL shortly.

Attachments:

  1. bug.go (688 bytes)
@robpike
Copy link
Contributor

robpike commented Jan 18, 2011

Comment 1:

Owner changed to r...@golang.org.

Status changed to Started.

@rsc
Copy link
Contributor

rsc commented Jan 19, 2011

Comment 2:

This issue was closed by revision eb56a79.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned robpike Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants