Creating URLs from rules with optional parameters

The way URL rules with optional parameters work seems strange from my point of view. Suppose we have a rule:


[

    'pattern' => 'post/<page:\d+>/<tag>',

    'route' => 'post/index',

    'defaults' => ['page' => 1],

],



I expect to get the


/post/1/foo

as an output from


Url::to('post/index', ['tag' => 'foo'])

since the “page” parameter should be default-initialized to “1”. Unfortunately rule doesn’t work without explicit “page” definition.

Is it by design or a bug? I don’t get it what’s the whole point of default parameters if I must always specify them explicitly. Why do the work only one way - while parsing and not also during creation?

Update: see corresponding issue