Skip to content
New issue

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

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

Already on GitHub? # to your account

"Use of uninitialized value $_ in split at ... Route.pm" when using optional megasplat #1144

Closed
Relequestual opened this issue Jan 4, 2016 · 6 comments

Comments

@Relequestual
Copy link
Contributor

When creating a route that uses an optional megasplat, and then accessing the route without the optional parts, warning thrown Use of uninitialized value $_ in split ..... Route.pm line 96.

Dancer version 1.3202

I'd like to be able to create a test which shows this, however I am unable to install the Safe module on osx, which is an auther dependency.

Example route:
/API/users/?**?

@bigpresh
Copy link
Member

bigpresh commented Feb 7, 2016

Sorry for the massive delay responding to this. I'll try to rock up a test to reproduce it, and get a fix in place.

@Relequestual
Copy link
Contributor Author

No worries at all. Ended up working round it by not actually needing to use megasplat.
Thanks again for your continued work on D1 maintenance =]

@bigpresh
Copy link
Member

bigpresh commented Feb 7, 2016

Yeah, able to reproduce against current master, simple test app that defines a route /foo/?**? - every time I hit it as just /foo I get a warning:

Use of uninitialized value $values[0] in split at .../Dancer/lib/Dancer/Route.pm line 137.

@Relequestual
Copy link
Contributor Author

Nice. I wonder if the same bug exists in D2.
If I had time this week to set up a VM and check it out, I would do!

bigpresh added a commit that referenced this issue Feb 7, 2016
This fixes issue #1144.

If you had a route with an optional megasplat, for example:

```perl
get '/foo/?**?' => sub { ... };
```

and you called it as `/foo`, you'd get a warning:

```
Use of uninitialized value $values[0] in split at
/home/davidp/dev/github/Dancer/lib/Dancer/Route.pm line 136.
```

This fixes it.  However you will still get an empty arrayref.  Part of me would
prefer it return undef instead of an empty arrayref in this case, but that would
be changing existing behaviour which apps in the wild may be relying upon, so
it' probably safest to maintain the same behaviour and just squash the warning.
bigpresh added a commit to PerlDancer/Dancer2 that referenced this issue Feb 7, 2016
This is the same bug reported in D1 as PerlDancer/Dancer#1144 - the bug was
also present in D2.

The D1 fix was in commit PerlDancer/Dancer@a5e54dc
@bigpresh
Copy link
Member

bigpresh commented Feb 7, 2016

This bug does indeed exist in D2. I've PR'd a fix for both :)

Thanks again for the report!

@bigpresh bigpresh closed this as completed Feb 7, 2016
@Relequestual
Copy link
Contributor Author

Skills! Especially given the time of day! Falling asleep myself!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants